acm.program
Class ConsoleProgram

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.ConsoleProgram
All Implemented Interfaces:
IOModel, ActionListener, KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, Runnable, EventListener, Accessible, RootPaneContainer

public abstract class ConsoleProgram
extends Program

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class acm.program.Program
CENTER, EAST, NORTH, SOUTH, WEST
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ConsoleProgram()
          Creates a new console program.
 
Method Summary
protected  IOConsole createConsole()
          Creates the console used by the ConsoleProgram.
 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.
 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.
 
Methods inherited from class acm.program.Program
actionPerformed, add, addActionListeners, addActionListeners, addExitHook, addImpl, createDialogIO, createMenuBar, createParameterTable, createProgramFrame, destroy, endHook, exit, getAppletStub, getArgumentArray, getBorder, getCentralRegionSize, getConsole, getDialog, getHeight, getInputModel, getLayout, getMainThread, getMenuBar, getOutputModel, getParameter, getParameterTable, getPreferredSize, getReader, getRegionPanel, getStartupObject, getTitle, getWidth, getWriter, isAppletMode, isStarted, keyPressed, keyReleased, keyTyped, main, menuAction, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, pause, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, readBoolean, readBoolean, readBoolean, readDouble, readDouble, readDouble, readDouble, readInt, readInt, readInt, readInt, readLine, readLine, remove, remove, removeAll, repaint, runHook, setAppletStub, setBackground, setConsole, setDialog, setInputModel, setLayout, setOutputModel, setParameter, setParameterTable, setStartupObject, setTitle, showErrorMessage, start, start, startHook, startRun, validate
 
Methods inherited from class javax.swing.JApplet
createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsoleProgram

public ConsoleProgram()
Creates a new console program.

Method Detail

createConsole

protected IOConsole createConsole()
Creates the console used by the ConsoleProgram.

Overrides:
createConsole in class Program
Returns:
The console to be used by the program

init

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.

Overrides:
init in class Program

run

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
Overrides:
run in class Program

setFont

public void setFont(Font font)
Sets the font for the console.

Overrides:
setFont in class Container
Parameters:
font - The new font

setFont

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

family-style-size

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

Parameters:
str - A String specifying the new font