|
Basic Methods zio package context |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object zio.DialogWindow
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.
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 |
public DialogWindow(java.lang.String title, java.lang.String initialMessage)
Method Detail |
public final void displayString(java.lang.String s)
String
message in the dialog window.
s
- the String
to be displayedpublic final void closeWindow()
public void processInput(java.lang.String userin)
String
. Create a subclass
and override this method to determine what response
will be made to the user.
userin
- count on this being the (possibly empty) string
the user has just input
|
author context |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |