Basic Methods
zio package

context

zio
Class DialogWindow


java.lang.Object

  extended byzio.DialogWindow


public class DialogWindow
extends java.lang.Object

Provides a window that can be used for a continuing dialog with the user. This class was created for teaching purposes and is meant to be used with the DisplayWindow class.

Responding to user input requires a different style of programming than the question and answer stye that was prevalent decades ago in command window. The user decides when and where to enter data. The effect of entering data must be to start some part of the program executing. In this case, that part of the program is the processInput() method. There is one parameter to processInput() and that is the String the user has just entered.

The processInput in this class does nothing! To write a useful program you have to make a subclass of DialogWindow (by extending it) and write your own version of processInput(). Here is a simple example that does not involve DisplayWindow.

 class Echo extends DialogWindow {
     public My Dialog() { 
        super("Echo","I will echo your input.");
     }
     public void processInput( String userin ) {
        displayString(userin);
     }
 }
 

Now this

   new Echo();
 

will create a window that echos user input.

Version:
Jul 22, 2005
Author:
copyright 2005 by J Adrian Zimmer
Licensed under the Open Software License version 2.1
See Also:
zio Dialog

Constructor Summary
DialogWindow(java.lang.String title, java.lang.String initialMessage)
          Create a dialog window with title and prompt.
 
Method Summary
 void closeWindow()
          Closes the window which means it is gone forever.
 void displayString(java.lang.String s)
          Display a String message in the dialog window.
 void processInput(java.lang.String userin)
          This method is invoked (but not by you) every time the user enters a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialogWindow


public DialogWindow(java.lang.String title,
                    java.lang.String initialMessage)
Create a dialog window with title and prompt. The title will be put in the window's title bar and the prompt is the initial message to the user. It will be put in the same place as all other messages to the user.

Method Detail

displayString


public final void displayString(java.lang.String s)
Display a String message in the dialog window.

Parameters:
s - the String to be displayed

closeWindow


public final void closeWindow()
Closes the window which means it is gone forever. Will not work if no other window is visible. Use Zio.stop() to stop a program.


processInput


public void processInput(java.lang.String userin)
This method is invoked (but not by you) every time the user enters a String. Create a subclass and override this method to determine what response will be made to the user.

Parameters:
userin - count on this being the (possibly empty) string the user has just input

author
context