acm.program
Class ConsoleProgram

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--acm.program.Program
                                      |
                                      +--acm.program.ConsoleProgram

public abstract class ConsoleProgram
extends Program

This class is a standard subclass of Program that installs a console in the window.


 
Constructor Summary
ConsoleProgram()
Creates a new console program.
 
Method Summary
void run()
Contains the code to be executed for each specific program subclass.
void setFont(Font font)
Sets the font for the console.
void setFont(String str)
Sets the font used for the console as specified by the string str, which is interpreted in the style of Font.decode.
 
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, which is expressed in milliseconds.
voidprint(String value)
Displays the argument value on the console, leaving the cursor at the end of the output.
voidprintln()
Advances the console cursor to the beginning of the next line.
voidprintln(String value)
Displays the argument value on the console and then advances the cursor to the next line.
booleanreadBoolean()
Reads and returns a boolean value (true or false).
booleanreadBoolean(String prompt)
Prompts the user to enter a boolean value.
booleanreadBoolean(String prompt, String trueLabel, String falseLabel)
Prompts the user to enter a boolean value, which is matched against the labels provided.
doublereadDouble()
Reads and returns a double-precision value from the user.
doublereadDouble(String prompt)
Prompts the user to enter a double-precision number.
intreadInt()
Reads and returns an integer value from the user.
intreadInt(String prompt)
Prompts the user to enter an integer.
StringreadLine()
Reads and returns a line of input from the console.
StringreadLine(String prompt)
Prompts the user for a line of input.
voidsetTitle(String title)
Sets the title of this program.
 

Constructor Detail

public ConsoleProgram()

Creates a new console program.

 
Usage: ConsoleProgram program = new ConsoleProgram(); 
 
Method Detail

public void run()

Contains the code to be executed for each specific program subclass. If you are defining your own ConsoleProgram class, you need to override the definition of run so that it contains the code for your application.

public void setFont(Font font)

Sets the font for the console.

 
Usage: program.setFont(font); 
Parameter: 
font  The new font
 

public void setFont(String str)

Sets the font used for the console as specified by the string str, which is interpreted in the style of Font.decode. The usual format of the font string is

   familycode>-stylecode>-size where both style and size are optional. If any of these parts are specified as an asterisk, the existing value is retained.


 
Usage: program.setFont(str); 
Parameter: 
str  A String specifying the new font