public abstract class Program extends javax.swing.JFrame implements IOModel, java.lang.Runnable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, java.awt.event.ActionListener
acm.program
package. Its principal role is to unify the concepts
of applets and applications in a single class, although it also provides
applications with many other useful facilities not traditionally available in
applications.
In many programming environments, objects that are specific instances of a
Program
subclass will run automatically without any special
action on your part. For maximum portability, you might want to define a
static main
method as described in the comments for the standard
implementation of main
.
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CENTER
Constant specifying the center of the container
|
static java.lang.String |
EAST
Constant specifying the east edge of the container
|
static java.lang.String |
NORTH
Constant specifying the north edge of the container
|
static java.lang.String |
SOUTH
Constant specifying the south edge of the container
|
static java.lang.String |
WEST
Constant specifying the west edge of the container
|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Modifier | Constructor and Description |
---|---|
protected |
Program()
This code initializes the program data structures.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Called when a component (typically a button) is activated.
|
void |
add(java.awt.Component comp,
java.lang.String region,
java.lang.Object constraints)
Adds the component to the specified border region with the indicated
constraints object.
|
void |
addActionListeners()
Adds the program as an
ActionListener to every button in the
structure that does not have a listener already. |
void |
addActionListeners(java.awt.event.ActionListener listener)
Adds the specified listener to every button in the structure that does not
have a listener already.
|
void |
addExitHook(java.lang.Object obj)
Requests that the program call the
exit method in the specified
object before exiting. |
protected void |
addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
Adds the specified component to the content pane using the specified
constraints and index.
|
protected IOConsole |
createConsole()
Creates the console used by the
ConsoleProgram . |
protected IODialog |
createDialogIO()
Creates the dialog used for interaction (primarily by the
DialogProgram class). |
protected ProgramMenuBar |
createMenuBar()
Creates a menu bar for use with the program.
|
protected static java.util.HashMap<java.lang.String,java.lang.String> |
createParameterTable(java.lang.String[] args)
Creates a hash table containing the parameters specified in the argument
list.
|
void |
destroy()
Called when the program has been told to destroy itself.
|
protected void |
endHook()
Performs class-specific cleanup for the program just after it finishes.
|
void |
exit()
Exits from the program.
|
protected java.lang.String[] |
getArgumentArray()
Retrieves the array of arguments passed in from the command line, or
null if no arguments are available. |
protected java.awt.Component |
getBorder(java.lang.String side)
Returns the component installed as a border on the specified side, which must
be one of the constants from
BorderLayout (NORTH ,
SOUTH , EAST , WEST ). |
java.awt.Dimension |
getCentralRegionSize()
Returns the size of the central region.
|
IOConsole |
getConsole()
Returns the console associated with this program.
|
IODialog |
getDialog()
Returns the dialog used for user interaction.
|
IOModel |
getInputModel()
Returns the
IOModel used for program input, which will
ordinarily be the console. |
java.awt.LayoutManager |
getLayout()
Gets the layout manager for the central region of the content pane.
|
java.lang.Thread |
getMainThread()
Returns the thread that is running the main program.
|
IOModel |
getOutputModel()
Returns the
IOModel used for program output, which will
ordinarily be the console. |
java.lang.String |
getParameter(java.lang.String name)
Returns the parameter associated with name.
|
protected java.util.HashMap<java.lang.String,java.lang.String> |
getParameterTable()
Retrieves the parameter table.
|
ProgramMenuBar |
getProgramMenuBar()
Returns the menu bar associated with this program.
|
java.io.BufferedReader |
getReader()
Returns a
BufferedReader whose input comes from the console. |
javax.swing.JPanel |
getRegionPanel(java.lang.String region)
Gets the
JPanel for the specified region. |
protected java.lang.Object |
getStartupObject()
Retrieves the object that was created when this program was started if that
object is something other than a
Program . |
java.io.PrintWriter |
getWriter()
Returns a
PrintWriter whose output is directed to the console. |
void |
init()
Specifies the code to be executed as startup time before the
run
method is called. |
protected boolean |
isStarted()
Checks to see whether this program has started, usually by checking to see
whether some pane exists.
|
void |
keyPressed(java.awt.event.KeyEvent e)
Called when a key is pressed.
|
void |
keyReleased(java.awt.event.KeyEvent e)
Called when a key is released.
|
void |
keyTyped(java.awt.event.KeyEvent e)
Called when a key is typed (i.e., pressed and released).
|
static void |
main(java.lang.String[] args)
Every application must either contain a "Main-Class" entry in its manifest
file or include a main method that looks like this, where
MyClass is the name of the program class: |
boolean |
menuAction(java.awt.event.ActionEvent e)
Called whenever a program action is detected in the menu bar.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the mouse is clicked.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Called when the mouse is dragged with the button down.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Called when the mouse enters the source (which may be either a component or a
GObject ). |
void |
mouseExited(java.awt.event.MouseEvent e)
Called when the mouse exits the source (which may be either a component or a
GObject ). |
void |
mouseMoved(java.awt.event.MouseEvent e)
Called when the mouse is moved.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Called when the mouse button is pressed.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Called when the mouse button is released.
|
void |
pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in
milliseconds.
|
void |
print(boolean x)
Makes sure that
print can display a boolean . |
void |
print(char x)
Makes sure that
print can display a char . |
void |
print(double x)
Makes sure that
print can display a double . |
void |
print(float x)
Makes sure that
print can display a float . |
void |
print(int x)
Makes sure that
print can display an int . |
void |
print(long x)
Makes sure that
print can display a long . |
void |
print(java.lang.Object x)
Makes sure that
print can display an Object . |
void |
print(java.lang.String value)
Displays the argument value on the console, leaving the cursor at the end of
the output.
|
void |
println()
Advances the console cursor to the beginning of the next line.
|
void |
println(boolean x)
Makes sure that
println can display a boolean . |
void |
println(char x)
Makes sure that
println can display a char . |
void |
println(double x)
Makes sure that
println can display a double . |
void |
println(float x)
Makes sure that
println can display a float . |
void |
println(int x)
Makes sure that
println can display an int . |
void |
println(long x)
Makes sure that
println can display a long . |
void |
println(java.lang.Object x)
Makes sure that
println can display an Object . |
void |
println(java.lang.String value)
Displays the argument value on the console and then advances the cursor to
the beginning of the next line.
|
boolean |
readBoolean()
Reads and returns a boolean value (
true or false ). |
boolean |
readBoolean(java.lang.String prompt)
Prompts the user to enter a boolean value, which is returned as the value of
this method.
|
boolean |
readBoolean(java.lang.String prompt,
java.lang.String trueLabel,
java.lang.String falseLabel)
Prompts the user to enter a boolean value, which is matched against the
labels provided.
|
double |
readDouble()
Reads and returns a double-precision value from the user.
|
double |
readDouble(double low,
double high)
Reads and returns a double-precision value from the user, which is
constrained to be within the specified inclusive range.
|
double |
readDouble(java.lang.String prompt)
Prompts the user to enter an double-precision number, which is then returned
as the value of this method.
|
double |
readDouble(java.lang.String prompt,
double low,
double high)
Prompts the user to enter an double-precision number, which is then returned
as the value of this method.
|
int |
readInt()
Reads and returns an integer value from the user.
|
int |
readInt(int low,
int high)
Reads and returns an integer value from the user, which is constrained to be
within the specified inclusive range.
|
int |
readInt(java.lang.String prompt)
Prompts the user to enter an integer, which is then returned as the value of
this method.
|
int |
readInt(java.lang.String prompt,
int low,
int high)
Prompts the user to enter an integer, which is then returned as the value of
this method.
|
java.lang.String |
readLine()
Reads and returns a line of input from the console.
|
java.lang.String |
readLine(java.lang.String prompt)
Prompts the user for a line of input.
|
void |
remove(java.awt.Component comp)
Removes the specified component from the central region.
|
void |
remove(int index)
Removes the component at the specified index from the central region.
|
void |
removeAll()
Removes all components from the central region.
|
void |
repaint()
Forwards repaint to the content pane.
|
void |
run()
Specifies the code to be executed as the program runs.
|
protected void |
runHook()
Calls the run method in the program.
|
void |
setBackground(java.awt.Color color)
Sets the background for the central region of the content pane.
|
void |
setConsole(IOConsole console)
Sets the console associated with this program.
|
void |
setContentSize(int width,
int height)
Sets the window size such that the content area meets the given dimensions.
|
void |
setDialog(IODialog dialog)
Sets the dialog associated with this program.
|
void |
setInputModel(IOModel io)
Sets the input model associated with this program.
|
void |
setLayout(java.awt.LayoutManager layout)
Sets the layout manager for the central region of the content pane.
|
void |
setOutputModel(IOModel io)
Sets the output model associated with this program.
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Sets a new value for the named parameter.
|
protected void |
setParameterTable(java.util.HashMap<java.lang.String,java.lang.String> ht)
Sets the parameter table for this program.
|
protected void |
setStartupObject(java.lang.Object obj)
Sets the object that is created when the program is started so that it can be
retrieved later by
getStartupObject . |
void |
showErrorMessage(java.lang.String msg)
Displays the error message in the standard output model.
|
void |
start()
Starts the program when it is running in application mode.
|
void |
start(java.lang.String[] args)
Starts the program using the specified argument list.
|
protected void |
startHook()
Performs class-specific initialization for the program just before it starts.
|
protected void |
startRun()
Initializes and runs the run method.
|
void |
validate()
Forwards validate to the content pane.
|
createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validateTree
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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String NORTH
public static final java.lang.String SOUTH
public static final java.lang.String EAST
public static final java.lang.String WEST
public static final java.lang.String CENTER
public void run()
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
iteration 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.run
in interface java.lang.Runnable
public void init()
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.public void print(java.lang.String value)
print
method is overloaded so that
value
can be of any type.public final void print(boolean x)
print
can display a boolean
.public final void print(char x)
print
can display a char
.public final void print(double x)
print
can display a double
.public final void print(float x)
print
can display a float
.public final void print(int x)
print
can display an int
.public final void print(long x)
print
can display a long
.public final void print(java.lang.Object x)
print
can display an Object
.public void println()
public void println(java.lang.String value)
println
method is overloaded
so that value
can be of any type.public final void println(boolean x)
println
can display a boolean
.public final void println(char x)
println
can display a char
.public final void println(double x)
println
can display a double
.public final void println(float x)
println
can display a float
.public final void println(int x)
println
can display an int
.public final void println(long x)
println
can display a long
.public final void println(java.lang.Object x)
println
can display an Object
.public void showErrorMessage(java.lang.String msg)
showErrorMessage
in interface IOModel
msg
- The error msg to be displayedpublic final java.lang.String readLine()
public java.lang.String readLine(java.lang.String prompt)
public final int readInt()
setExceptionOnError
method.public final int readInt(int low, int high)
setExceptionOnError
method.public final int readInt(java.lang.String prompt)
setExceptionOnError
method.public int readInt(java.lang.String prompt, int low, int high)
low
and high
. If the user types a value that is not
a legal integer or is outside the specified range, the method ordinarily
offers the user a chance to reenter the data, although this behavior can be
changed using the
setExceptionOnError
method.public final double readDouble()
setExceptionOnError
method.readDouble
in interface IOModel
double
public final double readDouble(double low, double high)
setExceptionOnError
method.readDouble
in interface IOModel
low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public final double readDouble(java.lang.String prompt)
setExceptionOnError
method.readDouble
in interface IOModel
prompt
- The prompt string to display to the userdouble
public double readDouble(java.lang.String prompt, double low, double high)
low
and high
. If the user types a value
that is not a legal number, the method ordinarily offers the user a chance to
reenter the data, although this behavior can be changed using the
setExceptionOnError
method.readDouble
in interface IOModel
prompt
- The prompt string to display to the userlow
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public final boolean readBoolean()
true
or false
).
The input must match one of these strings, ignoring case. If the user types a
value that is not one of these possibilities, the method ordinarily offers
the user a chance to reenter the data, although this behavior can be changed
using the
setExceptionOnError
method.readBoolean
in interface IOModel
public final boolean readBoolean(java.lang.String prompt)
setExceptionOnError
method.readBoolean
in interface IOModel
prompt
- The prompt string to display to the userpublic boolean readBoolean(java.lang.String prompt, java.lang.String trueLabel, java.lang.String falseLabel)
readBoolean
ordinarily offers the user a chance to
reenter the data, although this behavior can be changed using the
setExceptionOnError
method.readBoolean
in interface IOModel
prompt
- The prompt string to display to the usertrueLabel
- The string used to indicate true
falseLabel
- The string used to indicate false
public void setConsole(IOConsole console)
console
- The IOConsole
object used for this programpublic IOConsole getConsole()
IOConsole
object used for this programpublic void setDialog(IODialog dialog)
dialog
- The IODialog
object used for this programpublic IODialog getDialog()
IODialog
object used for this programpublic void setInputModel(IOModel io)
io
- The input model used for this programpublic void setOutputModel(IOModel io)
io
- The IOModel
object used as the output modelpublic IOModel getInputModel()
IOModel
used for program input, which will
ordinarily be the console.IOModel
used for program inputpublic IOModel getOutputModel()
IOModel
used for program output, which will
ordinarily be the console.IOModel
used for program outputpublic java.io.BufferedReader getReader()
BufferedReader
whose input comes from the console.Reader
for use with this consolepublic java.io.PrintWriter getWriter()
PrintWriter
whose output is directed to the console.PrintWriter
for use with this consolepublic javax.swing.JPanel getRegionPanel(java.lang.String region)
JPanel
for the specified region.region
- The region of the window (NORTH
,
SOUTH
, EAST
, WEST
, or
CENTER
)JPanel
for that subregionpublic void add(java.awt.Component comp, java.lang.String region, java.lang.Object constraints)
comp
- The component to be addedregion
- The region of the window (NORTH
,
SOUTH
, EAST
, WEST
,
or CENTER
)constraints
- The constraints objectpublic void addActionListeners()
ActionListener
to every button in the
structure that does not have a listener already.public void addActionListeners(java.awt.event.ActionListener listener)
listener
- The ActionListener
to be addedpublic ProgramMenuBar getProgramMenuBar()
createMenuBar
factory method.public void start(java.lang.String[] args)
args
- An array of strings passed to the programpublic void exit()
super.exit()
at the end of their processing.public void addExitHook(java.lang.Object obj)
exit
method in the specified
object before exiting.public void setParameter(java.lang.String name, java.lang.String value)
name
- The name of the parametervalue
- The new valuepublic java.lang.Thread getMainThread()
public void pause(double milliseconds)
Thread.sleep
, this method never throws an
exception.milliseconds
- The sleep time in millisecondspublic java.awt.Dimension getCentralRegionSize()
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
is
always preceded by both a mousePressed
and a
mouseReleased
event for the same source.mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
GObject
).mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
GObject
).mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
call is always
preceded by a mousePressed
call for the same source. If the
mouse is pressed elsewhere and then enters a source with the button down, no
drag event occurs. Moreover, once the mouse button goes down in a particular
source, only that source will receive mouse events until the button goes up.
Those events, moreover, are reported even in the mouse travels outside the
domain of the object.mouseDragged
in interface java.awt.event.MouseMotionListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
protected IOConsole createConsole()
ConsoleProgram
. Subclasses can
override this method to create their own console types.protected IODialog createDialogIO()
DialogProgram
class). Subclasses can override this method to
create their own dialog types.protected ProgramMenuBar createMenuBar()
Program
public void setContentSize(int width, int height)
width
- new width of the content area.height
- new height of the content area.public java.lang.String getParameter(java.lang.String name)
name
- The name of the parameternull
if nonepublic void setLayout(java.awt.LayoutManager layout)
setLayout
in class javax.swing.JFrame
layout
- The layout manager to usepublic java.awt.LayoutManager getLayout()
getLayout
in class java.awt.Container
public void setBackground(java.awt.Color color)
setBackground
in class java.awt.Frame
color
- The new background colorprotected void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
addImpl
in class javax.swing.JFrame
public void remove(int index)
remove
in class java.awt.Container
index
- The index position of the component to removepublic void remove(java.awt.Component comp)
remove
in class javax.swing.JFrame
comp
- The component to removepublic void removeAll()
removeAll
in class java.awt.Container
public void validate()
validate
in class java.awt.Container
public void repaint()
repaint
in class java.awt.Component
public final void start()
start
method in Applet
and therefore
will be called as part of applet startup.public void destroy()
public static void main(java.lang.String[] args)
MyClass
is the name of the program class:
public static void main(String[] args) {
new MyClass().start();
}
If the program needs the command line arguments, the args
array
can be passed to the start
method and then retrieved using the
getArgumentArray
method.
args
- An array of string argumentspublic boolean menuAction(java.awt.event.ActionEvent e)
protected java.awt.Component getBorder(java.lang.String side)
BorderLayout
(NORTH
,
SOUTH
, EAST
, WEST
).side
- The side (NORTH
, SOUTH
,
EAST
, or WEST
)protected java.lang.String[] getArgumentArray()
null
if no arguments are available.protected boolean isStarted()
protected void startHook()
protected void endHook()
protected void setParameterTable(java.util.HashMap<java.lang.String,java.lang.String> ht)
ht
- The parameter tableprotected java.util.HashMap<java.lang.String,java.lang.String> getParameterTable()
protected void setStartupObject(java.lang.Object obj)
getStartupObject
.obj
- The startup objectprotected java.lang.Object getStartupObject()
Program
. In the normal case of
running a Program
object, this method will return
null
.protected void startRun()
protected void runHook()
protected static java.util.HashMap<java.lang.String,java.lang.String> createParameterTable(java.lang.String[] args)
name=
value
All other arguments are collected as a tab-separated string and placed in an
entry under the key "ARGS"
. All named parameters are converted
to lower case to preserve the case-insensitive semantics of
getParameter
.
args
- The array of strings passed to the applicationHashMap
containing the parameter bindings