acm.program
Class DialogProgram

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by acm.program.Program
                          extended by acm.program.DialogProgram

public abstract class DialogProgram
extends Program

This class is a standard subclass of Program that takes its input from a IODialog object.


Field Summary
 
Constructor Summary
DialogProgram()
Creates a new dialog program.
 
Method Summary
 void init()
Specifies the code to be executed as startup time before the run method is called.
 void run()
Specifies the code to be executed as the program runs.
 
Inherited Method Summary
IOConsolegetConsole()
Returns the console associated with this program.
IODialoggetDialog()
Returns the dialog used for user interaction.
BufferedReadergetReader()
Returns a BufferedReader whose input comes from the console.
StringgetTitle()
Gets the title of this program.
PrintWritergetWriter()
Returns a PrintWriter whose output is directed to the console.
voidpause(double milliseconds)
Delays the calling thread for the specified time.
voidprint(String value)
Displays the argument value, allowing for the possibility of more output in the same dialog.
voidprintln()
Completes the output line and displays the dialog.
voidprintln(String value)
Adds the value to the current output line and then displays the dialog.
booleanreadBoolean()
Puts up a dialog box asking the user for a true/false value.
booleanreadBoolean(String prompt)
Puts up a dialog box asking the user for a true/false value.
booleanreadBoolean(String prompt, trueLabel, falseLabel)
Puts up a dialog box asking the user for a boolean value chosen from buttons with the specified labels.
doublereadDouble()
Puts up a dialog box asking the user for a double-precision number.
doublereadDouble(String prompt)
Puts up a dialog box asking the user for a double-precision number.
intreadInt()
Puts up a dialog box asking the user for an integer.
intreadInt(String prompt)
Puts up a dialog box asking the user for an integer.
StringreadLine()
Puts up a dialog box asking the user for a line of text.
StringreadLine(String prompt)
Puts up a dialog box asking the user for a line of text.
voidsetTitle(String title)
Sets the title of this program.
 

Constructor Detail

public DialogProgram()

Creates a new dialog program.

 
Usage: DialogProgram program = new DialogProgram(); 
 

Method Detail

public void init()

Specifies the code to be executed as startup time before the run method is called. Subclasses can override this method to perform any initialization code that would ordinarily be included in an applet init method. In general, subclasses will override init in GUI-based programs where the program simply sets up an initial state and then waits for events from the user. The run method is required for applications in which there needs to be some control thread while the program runs, as in a typical animation.

 
Usage: program.init(); 
 


public void run()

Specifies the code to be executed as the program runs. The run method is required for applications that have a thread of control that runs even in the absence of user actions, such as a program that uses console interation or that involves animation. GUI-based programs that operate by setting up an initial configuration and then wait for user events usually do not specify a run method and supply a new definition for init instead.

Specified by:
run in interface Runnable