public abstract class Program extends JApplet implements ActionListener, AdjustmentListener, ChangeListener, ComponentListener, ContainerListener, DocumentListener, FocusListener, acm.io.IOModel, ItemListener, KeyListener, ListDataListener, ListSelectionListener, MouseListener, MouseInputListener, MouseMotionListener, MouseWheelListener, PopupMenuListener, ProgramInterface, Runnable, TextListener, WindowFocusListener, WindowListener, WindowStateListener
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
.
JApplet.AccessibleJApplet
Applet.AccessibleApplet
Panel.AccessibleAWTPanel
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected static String |
CONFIG_FILE_NAME |
protected Set<GObject> |
invisibleObjects |
accessibleContext, rootPane, rootPaneCheckingEnabled
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Modifier | Constructor and Description |
---|---|
protected |
Program()
This code initializes the program data structures.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Called when a component (typically a button) is activated.
|
void |
add(Component comp,
String region,
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(ActionListener listener)
Adds the specified listener to every button in
the structure that does not have a listener already.
|
void |
addActionListenersToButtonsOnly()
Adds the program as an
ActionListener to every button in
the structure that does not have a listener already. |
void |
addAllActionListeners()
Adds the program as an
ActionListener to every button or component in
the structure that does not have a listener already. |
void |
addExitHook(Object obj)
Requests that the program call the
exit method in the
specified object before exiting. |
protected void |
addImpl(Component comp,
Object constraints,
int index)
Adds the specified component to the content pane using the specified constraints and index.
|
void |
adjustmentValueChanged(AdjustmentEvent e)
Required empty method of AdjustmentListener interface.
|
void |
alert(Object value)
Pops up a dialog box displaying a string representation of the given message.
|
void |
alert(String message)
Pops up a dialog box displaying the given message.
|
void |
animation()
Override this method to indicate what to do on every frame advance
in an animated program after setAnimated(true) is called.
|
void |
center()
Moves this program's window to the center of the screen.
|
void |
changedUpdate(DocumentEvent e)
Required method of DocumentListener interface.
|
protected void |
checkCompilerFlags() |
void |
checkKill()
Checks whether the program has been stopped via the killMe method.
|
protected void |
checkStartupSettings() |
void |
componentAdded(ContainerEvent e)
Required method of ContainerListener interface.
|
void |
componentHidden(ComponentEvent e)
Required method of ComponentListener interface.
|
void |
componentMoved(ComponentEvent e)
Required method of ComponentListener interface.
|
void |
componentRemoved(ContainerEvent e)
Required method of ContainerListener interface.
|
void |
componentResized(ComponentEvent e)
Required method of ComponentListener interface.
|
void |
componentShown(ComponentEvent e)
Required method of ComponentListener interface.
|
boolean |
confirm(String question)
Pops up a dialog box displaying the given message and asking the user to choose Yes or No.
|
void |
contentsChanged(ListDataEvent e)
Required method of ListDataListener interface.
|
protected IOConsole |
createConsole()
Creates the console used by the
ConsoleProgram . |
protected acm.io.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 Map<String,String> |
createParameterTable(String[] args)
Creates a hash table containing the parameters specified in the
argument list.
|
protected JFrame |
createProgramFrame()
Creates the frame containing the program.
|
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 |
error(Exception ex)
Generates an ErrorException with the given exception as its cause.
|
void |
error(Exception ex,
String text)
Generates an ErrorException with the given exception and text.
|
void |
error(String text)
Generates an ErrorException with the given text as its error message.
|
void |
exit()
Exits from the program.
|
protected boolean |
fileExists(String filename)
Returns true if the given file exists within the current working directory.
|
protected boolean |
fileExists(String directory,
String filename)
Returns true if the given file exists within the given directory.
|
protected boolean |
fileExistsInsideJAR(String filename)
Returns true if the given file exists inside the app's JAR archive within the current working directory.
|
protected boolean |
fileExistsInsideJAR(String directory,
String filename)
Returns true if the given file exists inside the app's JAR archive within the given directory.
|
protected boolean |
fileExistsOnDisk(String filename)
Returns true if the given file exists in the current working directory.
|
protected boolean |
fileExistsOnDisk(String directory,
String filename)
Returns true if the given file exists in the given directory.
|
protected int |
fileSize(String filename)
Returns the size of the given file in bytes in the current working directory.
|
protected int |
fileSize(String directory,
String filename)
Returns the size of the given file in bytes.
|
void |
focusGained(FocusEvent e)
Required empty method of FocusListener interface; does nothing.
|
void |
focusLost(FocusEvent e)
Required empty method of FocusListener interface; does nothing.
|
int |
getAnimationDelay()
Returns the delay between frames of animation in milliseconds (default 20).
|
protected AppletStub |
getAppletStub()
Retrieves the applet stub.
|
protected String[] |
getArgumentArray()
Retrieves the array of arguments passed in from the command line, or
null if no arguments are available. |
boolean |
getBoolean()
Reads and returns a boolean value (
true or false ). |
boolean |
getBoolean(String prompt)
Prompts the user to enter a boolean value, which is returned as
the value of this method.
|
boolean |
getBoolean(String prompt,
String trueLabel,
String falseLabel)
Prompts the user to enter a boolean value, which is matched against the
labels provided.
|
protected Component |
getBorder(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 ). |
int |
getBottomY()
Returns the y-coordinate of the bottom of this program's window.
|
acm.graphics.GDimension |
getCenterLocation()
Returns the x/y-coordinates of the center of this program's window.
|
int |
getCenterX()
Returns the x-coordinate of the center of this program's window.
|
int |
getCenterY()
Returns the y-coordinate of the center of this program's window.
|
Dimension |
getCentralRegionSize()
Returns the size of the central region.
|
IOConsole |
getConsole()
Returns the console associated with this program.
|
acm.io.IODialog |
getDialog()
Returns the dialog used for user interaction.
|
double |
getDouble()
Reads and returns a double-precision value from the user.
|
double |
getDouble(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 |
getDouble(String prompt)
Prompts the user to enter an double-precision number, which is then
returned as the value of this method.
|
double |
getDouble(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 |
getHeight()
Returns the height of the central region.
|
acm.io.IOModel |
getInputModel()
Returns the
IOModel used for program input, which will
ordinarily be the console. |
int |
getInteger()
Reads and returns an integer value from the user.
|
int |
getInteger(int low,
int high)
Reads and returns an integer value from the user, which is constrained to
be within the specified inclusive range.
|
int |
getInteger(String prompt)
Prompts the user to enter an integer, which is then returned as the value
of this method.
|
int |
getInteger(String prompt,
int low,
int high)
Prompts the user to enter an integer, which is then returned as the value
of this method.
|
JFrame |
getJFrame()
Returns the Java Swing window frame that encloses this program.
|
LayoutManager |
getLayout()
Gets the layout manager for the central region of the content pane.
|
String |
getLine()
Reads and returns a line of input from the console.
|
String |
getLine(String prompt)
Prompts the user for a line of input.
|
Thread |
getMainThread()
Returns the thread that is running the main program.
|
ProgramMenuBar |
getMenuBar()
Returns the menu bar associated with this program.
|
Color |
getOutputColor()
Returns the current output color used to display output on the console.
|
acm.io.IOModel |
getOutputModel()
Returns the
IOModel used for program output, which will
ordinarily be the console. |
String |
getParameter(String name)
Returns the parameter associated with name.
|
protected Map<String,String> |
getParameterTable()
Retrieves the parameter table.
|
Dimension |
getPreferredSize()
Returns the preferred size of the content pane.
|
BufferedReader |
getReader()
Returns a
BufferedReader whose input comes from the console. |
double |
getReal()
Reads and returns a double-precision value from the user.
|
double |
getReal(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 |
getReal(String prompt)
Prompts the user to enter an double-precision number, which is then
returned as the value of this method.
|
double |
getReal(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.
|
JPanel |
getRegionPanel(String region)
Gets the
JPanel for the specified region. |
int |
getRightX()
Returns the x-coordinate of the right edge of this program's window.
|
int |
getScreenHeight()
Returns the height of the screen in pixels.
|
acm.graphics.GDimension |
getScreenSize()
Returns the width x height of the screen in pixels.
|
int |
getScreenWidth()
Returns the width of the screen in pixels.
|
protected Object |
getStartupObject()
Retrieves the object that was created when this program was started
if that object is something other than a
Program . |
String |
getTitle()
Gets the title of this program.
|
int |
getWidth()
Returns the width of the central region.
|
Window |
getWindow()
Returns the Java Swing window that encloses this program.
|
PrintWriter |
getWriter()
Returns a
PrintWriter whose output is directed to the console. |
boolean |
getYesOrNo(String prompt)
Prompts the user to answer a yes/no question and returns true if the user
typed 'yes' (or anything that starts with a 'y', case-insensitively),
false if the user types anything that starts with 'n', or re-prompts if
the user doesn't type a 'y' or 'n' word.
|
boolean |
hasConfiguration()
Returns true if this program has any saved configuration stored on disk.
|
void |
init()
Specifies the code to be executed as startup time before the
run method is called. |
void |
insertUpdate(DocumentEvent e)
Required method of DocumentListener interface.
|
void |
intervalAdded(ListDataEvent e)
Required method of ListDataListener interface.
|
void |
intervalRemoved(ListDataEvent e)
Required method of ListDataListener interface.
|
boolean |
isAnimated()
Returns true if the program is currently in animated mode.
|
protected boolean |
isApplet()
Returns
true if this program is running as an applet in a browser. |
boolean |
isAppletMode()
Returns
true if this program is running as an applet in a browser. |
boolean |
isExitOnClose()
Returns whether the program will exit when its window is closed (default true).
|
boolean |
isInitialized()
Returns true if this program's init() method has been called.
|
protected boolean |
isStarted()
Checks to see whether this program has started, usually by checking to see
whether some pane exists.
|
void |
itemStateChanged(ItemEvent e)
Required empty method of ItemListener interface.
|
void |
keyPressed(KeyEvent e)
Called when a key is pressed.
|
void |
keyReleased(KeyEvent e)
Called when a key is released.
|
void |
keyTyped(KeyEvent e)
Called when a key is typed (i.e., pressed and released).
|
void |
killMe()
Instructs the program to stop/kill itself.
|
void |
loadConfiguration()
Loads any saved configuration of this program from disk.
|
protected void |
loadConfiguration(Properties props)
Loads any saved configuration of this program from disk.
|
static void |
main(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(ActionEvent event)
Called whenever a program action is detected in the menu bar.
|
void |
menuCanceled(MenuEvent e)
Required method of MenuListener interface.
|
void |
menuDeselected(MenuEvent e)
Required method of MenuListener interface.
|
void |
menuSelected(MenuEvent e)
Required method of MenuListener interface.
|
void |
mouseClicked(MouseEvent e)
Called when the mouse is clicked.
|
void |
mouseDragged(MouseEvent e)
Called when the mouse is dragged with the button down.
|
void |
mouseEntered(MouseEvent e)
Called when the mouse enters the source (which may be
either a component or a
GObject ). |
void |
mouseExited(MouseEvent e)
Called when the mouse exits the source (which may be
either a component or a
GObject ). |
void |
mouseMoved(MouseEvent e)
Called when the mouse is moved.
|
void |
mousePressed(MouseEvent e)
Called when the mouse button is pressed.
|
void |
mouseReleased(MouseEvent e)
Called when the mouse button is released.
|
void |
mouseWheelMoved(MouseWheelEvent e)
Implementation of MouseWheelListener interface.
|
protected InputStream |
openFile(String filename)
Opens the given file for reading.
|
protected InputStream |
openFile(String directory,
String filename)
Opens the given file from within the given directory.
|
protected InputStream |
openFileFromDisk(String filename)
Opens the given file from within the current working directory.
|
protected InputStream |
openFileFromDisk(String directory,
String filename)
Opens the given file from within the given directory.
|
protected InputStream |
openFileFromJAR(String filename)
Opens the given file from inside the app's JAR archive.
|
protected InputStream |
openFileFromJAR(String directory,
String filename)
Opens the given file from within the app's JAR archive in the given directory.
|
void |
pack()
Resizes this program to exactly fit the preferred size of its contents.
|
void |
pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in
milliseconds.
|
void |
pauseTick()
Sets a 'pause tick' flag.
|
void |
popupMenuCanceled(PopupMenuEvent e)
Required method of PopupMenuListener interface.
|
void |
popupMenuWillBecomeInvisible(PopupMenuEvent e)
Required method of PopupMenuListener interface.
|
void |
popupMenuWillBecomeVisible(PopupMenuEvent e)
Required method of PopupMenuListener interface.
|
void |
print(boolean x)
Makes sure that
print can display a boolean . |
void |
print(boolean value,
Color color)
Prints the given value in the given color.
|
void |
print(char x)
Makes sure that
print can display a char . |
void |
print(char value,
Color color)
Prints the given value in the given color.
|
void |
print(double x)
Makes sure that
print can display a double . |
void |
print(double value,
Color color)
Prints the given value in the given color.
|
void |
print(float x)
Makes sure that
print can display a float . |
void |
print(float value,
Color color)
Prints the given value in the given color.
|
void |
print(int x)
Makes sure that
print can display an int . |
void |
print(int value,
Color color)
Prints the given value in the given color.
|
void |
print(long x)
Makes sure that
print can display a long . |
void |
print(long value,
Color color)
Prints the given value in the given color.
|
void |
print(Object x)
Makes sure that
print can display an Object . |
void |
print(Object value,
Color color)
Prints the given value in the given color.
|
void |
print(String value)
Displays the argument value on the console, leaving the cursor at the end of
the output.
|
void |
print(String value,
Color color)
Prints the given string in the given color.
|
void |
printf(String format,
Object... args)
Writes a formatted string to this output stream using the specified format string and arguments.
|
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(boolean value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(char x)
Makes sure that
println can display a char . |
void |
println(char value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(double x)
Makes sure that
println can display a double . |
void |
println(double value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(float x)
Makes sure that
println can display a float . |
void |
println(float value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(int x)
Makes sure that
println can display an int . |
void |
println(int value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(long x)
Makes sure that
println can display a long . |
void |
println(long value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(Object x)
Makes sure that
println can display an Object . |
void |
println(Object value,
Color color)
Prints the given value in the given color and then advances the cursor to the beginning of the next line.
|
void |
println(String value)
Displays the argument value on the console and then advances the cursor
to the beginning of the next line.
|
void |
println(String value,
Color color)
Prints the given string in the given color and then advances the cursor to the beginning of the next line.
|
String |
prompt(String prompt)
Pops up a dialog box displaying the given message and asking the user to type a response.
|
boolean |
readBoolean()
Reads and returns a boolean value (
true or false ). |
boolean |
readBoolean(String prompt)
Prompts the user to enter a boolean value, which is returned as
the value of this method.
|
boolean |
readBoolean(String prompt,
String trueLabel,
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(String prompt)
Prompts the user to enter an double-precision number, which is then
returned as the value of this method.
|
double |
readDouble(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(String prompt)
Prompts the user to enter an integer, which is then returned as the value
of this method.
|
int |
readInt(String prompt,
int low,
int high)
Prompts the user to enter an integer, which is then returned as the value
of this method.
|
String |
readLine()
Reads and returns a line of input from the console.
|
String |
readLine(String prompt)
Prompts the user for a line of input.
|
void |
remove(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 |
removeFromRegion(Component comp,
String region)
Removes the specified component from the specified region of this program window.
|
void |
removeMenuBar()
Removes the JMenuBar at the top of the program window.
|
void |
removeUpdate(DocumentEvent e)
Required method of DocumentListener interface.
|
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 |
saveConfiguration()
Saves configuration of this program to disk.
|
protected void |
saveConfiguration(Properties props)
Saves configuration of this program to disk in the given properties collection.
|
void |
setAnimated(boolean value)
Sets the program to be in animated (true) or non-animated (false) mode.
|
void |
setAnimationDelay(int delayMS)
Sets the number of milliseconds to delay between frames of animation.
|
protected void |
setAppletStub(AppletStub stub)
Sets the applet stub for this program in a way that makes it possible for
clients to retrieve it.
|
void |
setBackground(Color color)
Sets the background for the central region of the content pane.
|
void |
setBottomY(double y)
Sets the y location of the bottom of this program.
|
void |
setCenterLocation(double x,
double y)
Sets the y location of the horizontal and vertical center of this program.
|
void |
setCenterX(double x)
Sets the x location of the horizontal center of this program.
|
void |
setCenterY(double y)
Sets the y location of the vertical center of this program.
|
void |
setConsole(IOConsole console)
Sets the console associated with this program.
|
void |
setDialog(acm.io.IODialog dialog)
Sets the dialog associated with this program.
|
void |
setExitOnClose(boolean exitOnClose)
Sets whether the program will exit when its window is closed (default true).
|
void |
setFramesPerSecond(int fps)
Sets the animation delay properly to produce the given number of frames
per second of animation.
|
void |
setHeight(double height)
Sets the height of this program without changing its width.
|
void |
setInputModel(acm.io.IOModel io)
Sets the input model associated with this program.
|
void |
setInvisible(GObject obj,
boolean invisible)
Marks the given GObject as being 'invisible'.
|
void |
setJFrame(JFrame jframe)
Sets the Java Swing window frame that encloses this program.
|
void |
setJMenuBar(JMenuBar bar)
Sets the JMenuBar at the top of the program window to be the given menu bar.
|
void |
setLayout(LayoutManager layout)
Sets the layout manager for the central region of the content pane.
|
void |
setLocation(double x,
double y)
Sets the (x, y) location of the top-left corner of this program.
|
void |
setLocation(GPoint point)
Sets the (x, y) location of the top-left corner of this program.
|
void |
setOutputColor(Color color)
Sets the current output color used to display output on the console.
|
void |
setOutputModel(acm.io.IOModel io)
Sets the output model associated with this program.
|
void |
setParameter(String name,
String value)
Sets a new value for the named parameter.
|
void |
setParameterTable(Map<String,String> ht)
Sets the parameter table for this program.
|
void |
setPauseScaleFactor(double factor)
Applies a scaling factor to the duration of pause() calls.
|
void |
setResizable(boolean resizable)
Sets the title of this program.
|
void |
setRightX(double x)
Sets the x location of the right edge of this program.
|
void |
setShowPixelGrid(boolean show)
Sets whether to display a grid of horizontal and vertical lines on this canvas
for debugging, if this program contains a graphical canvas.
|
void |
setShowPixelInfo(boolean show)
Sets whether to display information on this canvas about the current pixel where
the mouse pointer is resting in this program's graphical canvas, if this program
contains a graphical canvas.
|
void |
setSize(double width,
double height)
Sets the width and height of this program.
|
void |
setStartupObject(Object obj)
Sets the object that is created when the program is started so that
it can be retrieved later by
getStartupObject . |
void |
setTitle(String title)
Sets the title of this program.
|
void |
setWidth(double width)
Sets the width of this program without changing its height.
|
void |
setX(double x)
Sets the x location of the top-left corner of this program.
|
void |
setY(double y)
Sets the y location of the top-left corner of this program.
|
void |
showErrorMessage(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(String[] args)
Starts the program using the specified argument list.
|
void |
startAnimation()
Sets the program into animated mode.
|
protected void |
startHook()
Performs class-specific initialization for the program just before
it starts.
|
protected void |
startRun()
Initializes and runs the run method.
|
void |
stateChanged(ChangeEvent event)
Required method of ChangeListener interface.
|
void |
stopAnimation()
Sets the program into non-animated (default) mode.
|
void |
textValueChanged(TextEvent e)
Required method of TextListener interface.
|
void |
validate()
Forwards validate to the content pane.
|
void |
valueChanged(ListSelectionEvent e)
Required method of ListSelectionListener interface.
|
void |
windowActivated(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowClosed(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowClosing(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowDeactivated(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowDeiconified(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowGainedFocus(WindowEvent e)
Required empty method of WindowFocusListener interface.
|
void |
windowIconified(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowLostFocus(WindowEvent e)
Required empty method of WindowFocusListener interface.
|
void |
windowOpened(WindowEvent event)
Required empty method of WindowListener interface.
|
void |
windowStateChanged(WindowEvent e)
Required empty method of WindowStateListener interface.
|
createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, repaint, setContentPane, setGlassPane, setLayeredPane, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
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, 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, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, 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, transferFocusBackward, transferFocusUpCycle
protected static final String CONFIG_FILE_NAME
public void contentsChanged(ListDataEvent e)
contentsChanged
in interface ListDataListener
public void intervalAdded(ListDataEvent e)
intervalAdded
in interface ListDataListener
public void intervalRemoved(ListDataEvent e)
intervalRemoved
in interface ListDataListener
public void menuCanceled(MenuEvent e)
public void menuDeselected(MenuEvent e)
public void menuSelected(MenuEvent e)
public void popupMenuCanceled(PopupMenuEvent e)
popupMenuCanceled
in interface PopupMenuListener
public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
popupMenuWillBecomeInvisible
in interface PopupMenuListener
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
popupMenuWillBecomeVisible
in interface PopupMenuListener
public void valueChanged(ListSelectionEvent e)
valueChanged
in interface ListSelectionListener
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void add(Component comp, String region, 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(ActionListener listener)
listener
- The ActionListener
to be addedpublic void addActionListenersToButtonsOnly()
ActionListener
to every button in
the structure that does not have a listener already.
Also adds action listeners to other components that have action commands.public void addAllActionListeners()
ActionListener
to every button or component in
the structure that does not have a listener already.
Also adds action listeners to other components that have action commands.public void addExitHook(Object obj)
exit
method in the
specified object before exiting.protected void addImpl(Component comp, Object constraints, int index)
public void adjustmentValueChanged(AdjustmentEvent e)
adjustmentValueChanged
in interface AdjustmentListener
public void alert(Object value)
value
- the value to display (its toString() method is implicitly called)public void alert(String message)
value
- the value to displaypublic void animation()
public void center()
public void changedUpdate(DocumentEvent e)
changedUpdate
in interface DocumentListener
protected void checkCompilerFlags()
public void checkKill()
protected void checkStartupSettings()
public void componentAdded(ContainerEvent e)
componentAdded
in interface ContainerListener
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentRemoved(ContainerEvent e)
componentRemoved
in interface ContainerListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public boolean confirm(String question)
value
- the value to displayprotected IOConsole createConsole()
ConsoleProgram
. Subclasses can
override this method to create their own console types.protected acm.io.IODialog createDialogIO()
DialogProgram
class). Subclasses can override this method to create their own dialog types.protected ProgramMenuBar createMenuBar()
Program
protected static Map<String,String> createParameterTable(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 bindingsprotected JFrame createProgramFrame()
Frame
objectpublic void destroy()
protected void endHook()
public void error(Exception ex)
public void error(Exception ex, String text)
public void error(String text)
public void exit()
super.exit()
at the end of their processing.exit
in interface ProgramInterface
protected boolean fileExists(String filename)
filename
- name of the file.protected boolean fileExists(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.protected boolean fileExistsInsideJAR(String filename)
directory
- directory to search for the file.filename
- name of the file.protected boolean fileExistsInsideJAR(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.protected boolean fileExistsOnDisk(String filename)
filename
- name of the file.protected boolean fileExistsOnDisk(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.protected int fileSize(String filename)
filename
- name of the file.IORuntimeException
- if file is not found or cannot be readprotected int fileSize(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.IORuntimeException
- if file is not found or cannot be readpublic void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void focusLost(FocusEvent e)
focusLost
in interface FocusListener
public int getAnimationDelay()
protected AppletStub getAppletStub()
protected String[] getArgumentArray()
null
if no arguments are available.public final boolean getBoolean()
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.public boolean getBoolean(String prompt)
setExceptionOnError
method.prompt
- The prompt string to display to the userpublic boolean getBoolean(String prompt, String trueLabel, String falseLabel)
readBoolean
ordinarily offers the user a chance
to reenter the data, although this behavior can be changed using the
setExceptionOnError
method.prompt
- The prompt string to display to the usertrueLabel
- The string used to indicate true
falseLabel
- The string used to indicate false
protected Component getBorder(String side)
BorderLayout
(NORTH
,
SOUTH
, EAST
, WEST
).side
- The side (NORTH
, SOUTH
, EAST
,
or WEST
)public int getBottomY()
public acm.graphics.GDimension getCenterLocation()
public int getCenterX()
public int getCenterY()
public Dimension getCentralRegionSize()
public IOConsole getConsole()
IOConsole
object used for this programpublic acm.io.IODialog getDialog()
IODialog
object used for this programpublic double getDouble()
setExceptionOnError
method.double
public double getDouble(double low, double high)
setExceptionOnError
method.low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public final double getDouble(String prompt)
setExceptionOnError
method.prompt
- The prompt string to display to the userdouble
public double getDouble(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.prompt
- The prompt string to display to the userlow
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public int getHeight()
public acm.io.IOModel getInputModel()
IOModel
used for program input, which will
ordinarily be the console.IOModel
used for program inputpublic int getInteger()
setExceptionOnError
method.public int getInteger(int low, int high)
setExceptionOnError
method.low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangepublic final int getInteger(String prompt)
setExceptionOnError
method.prompt
- The prompt string to display to the userpublic int getInteger(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.prompt
- The prompt string to display to the userlow
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangepublic JFrame getJFrame()
public LayoutManager getLayout()
public String getLine()
String
public String getLine(String prompt)
prompt
- The prompt string to display to the userString
public Thread getMainThread()
public ProgramMenuBar getMenuBar()
createMenuBar
factory method.public Color getOutputColor()
public acm.io.IOModel getOutputModel()
IOModel
used for program output, which will
ordinarily be the console.IOModel
used for program outputpublic String getParameter(String name)
getParameter
in class Applet
name
- The name of the parameternull
if noneprotected Map<String,String> getParameterTable()
public Dimension getPreferredSize()
getPreferredSize
in class Container
public BufferedReader getReader()
BufferedReader
whose input comes from the console.Reader
for use with this consolepublic double getReal()
setExceptionOnError
method.double
public double getReal(double low, double high)
setExceptionOnError
method.low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public final double getReal(String prompt)
setExceptionOnError
method.prompt
- The prompt string to display to the userdouble
public double getReal(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.prompt
- The prompt string to display to the userlow
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public JPanel getRegionPanel(String region)
JPanel
for the specified region.region
- The region of the window (NORTH
, SOUTH
,
EAST
, WEST
, or CENTER
)JPanel
for that subregionpublic int getRightX()
public int getScreenHeight()
public acm.graphics.GDimension getScreenSize()
public int getScreenWidth()
protected Object getStartupObject()
Program
. In
the normal case of running a Program
object, this method
will return null
.public String getTitle()
getTitle
in interface ProgramInterface
public int getWidth()
public Window getWindow()
public PrintWriter getWriter()
PrintWriter
whose output is directed to the console.PrintWriter
for use with this consolepublic boolean getYesOrNo(String prompt)
public final boolean hasConfiguration()
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.init
in interface ProgramInterface
init
in class Applet
public void insertUpdate(DocumentEvent e)
insertUpdate
in interface DocumentListener
public boolean isAnimated()
protected boolean isApplet()
true
if this program is running as an applet in a browser.public boolean isAppletMode()
true
if this program is running as an applet in a browser.true
if this program is running as an applet, false
otherwisepublic boolean isExitOnClose()
public boolean isInitialized()
protected boolean isStarted()
public void itemStateChanged(ItemEvent e)
itemStateChanged
in interface ItemListener
public void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
public void keyTyped(KeyEvent e)
keyTyped
in interface KeyListener
public void killMe()
public final void loadConfiguration()
protected void loadConfiguration(Properties props)
props
- properties to load frompublic boolean menuAction(ActionEvent event)
public void mouseClicked(MouseEvent e)
mouseClicked
is always preceded by both a mousePressed
and a
mouseReleased
event for the same source.mouseClicked
in interface MouseListener
public void mouseDragged(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 MouseMotionListener
public void mouseEntered(MouseEvent e)
GObject
).mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
GObject
).mouseExited
in interface MouseListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseWheelMoved(MouseWheelEvent e)
mouseWheelMoved
in interface MouseWheelListener
protected InputStream openFile(String filename)
filename
- name of the file.IORuntimeException
- if file is not foundprotected InputStream openFile(String directory, String filename)
filename
- name of the file.IORuntimeException
- if file is not foundprotected InputStream openFileFromDisk(String filename)
filename
- name of the file.IORuntimeException
- if file is not foundprotected InputStream openFileFromDisk(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.IORuntimeException
- if file is not foundprotected InputStream openFileFromJAR(String filename)
filename
- name of the file.IORuntimeException
- if file is not foundprotected InputStream openFileFromJAR(String directory, String filename)
directory
- directory to search for the file.filename
- name of the file.IORuntimeException
- if file is not foundpublic void pack()
public void pause(double milliseconds)
Thread.sleep
, this method never throws an
exception.pause
in interface ProgramInterface
milliseconds
- The sleep time in millisecondspublic void pauseTick()
public final void print(boolean x)
print
can display a boolean
.print
in interface acm.io.IOModel
public void print(boolean value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(char x)
print
can display a char
.print
in interface acm.io.IOModel
public void print(char value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(double x)
print
can display a double
.print
in interface acm.io.IOModel
public void print(double value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(float x)
print
can display a float
.print
in interface acm.io.IOModel
public void print(float value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(int x)
print
can display an int
.print
in interface acm.io.IOModel
public void print(int value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(long x)
print
can display a long
.print
in interface acm.io.IOModel
public void print(long value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void print(Object x)
print
can display an Object
.print
in interface acm.io.IOModel
print
in interface ProgramInterface
public void print(Object value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public void print(String value)
print
method is overloaded so that
value
can be of any type.print
in interface acm.io.IOModel
print
in interface ProgramInterface
value
- The value to be displayedpublic void print(String value, Color color)
value
- The string to print.color
- The color in which to draw the text. If null, draws in black.public void printf(String format, Object... args)
printf
in interface ProgramInterface
format
- A format string as described in Java's Format string syntax.args
- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Javaâ„¢ Virtual Machine Specification. The behavior on a null argument depends on the conversion.IllegalFormatException
- If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions.NullPointerException
- If the format is nullpublic void println()
println
in interface acm.io.IOModel
println
in interface ProgramInterface
public final void println(boolean x)
println
can display a boolean
.println
in interface acm.io.IOModel
public void println(boolean value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(char x)
println
can display a char
.println
in interface acm.io.IOModel
public void println(char value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(double x)
println
can display a double
.println
in interface acm.io.IOModel
public void println(double value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(float x)
println
can display a float
.println
in interface acm.io.IOModel
public void println(float value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(int x)
println
can display an int
.println
in interface acm.io.IOModel
public void println(int value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(long x)
println
can display a long
.println
in interface acm.io.IOModel
public void println(long value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public final void println(Object x)
println
can display an Object
.println
in interface acm.io.IOModel
println
in interface ProgramInterface
public void println(Object value, Color color)
value
- The value to print.color
- The color in which to draw the value. If null, draws in black.public void println(String value)
println
method is
overloaded so that value
can be of any type.println
in interface acm.io.IOModel
println
in interface ProgramInterface
value
- The value to be displayedpublic void println(String value, Color color)
value
- The string to print.color
- The color in which to draw the text. If null, draws in black.public String prompt(String prompt)
value
- the value to displaypublic 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 acm.io.IOModel
public final boolean readBoolean(String prompt)
setExceptionOnError
method.readBoolean
in interface acm.io.IOModel
prompt
- The prompt string to display to the userpublic boolean readBoolean(String prompt, String trueLabel, 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 acm.io.IOModel
prompt
- The prompt string to display to the usertrueLabel
- The string used to indicate true
falseLabel
- The string used to indicate false
public final double readDouble()
setExceptionOnError
method.readDouble
in interface acm.io.IOModel
double
public final double readDouble(double low, double high)
setExceptionOnError
method.readDouble
in interface acm.io.IOModel
low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangedouble
public final double readDouble(String prompt)
setExceptionOnError
method.readDouble
in interface acm.io.IOModel
prompt
- The prompt string to display to the userdouble
public double readDouble(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 acm.io.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 int readInt()
setExceptionOnError
method.readInt
in interface acm.io.IOModel
public final int readInt(int low, int high)
setExceptionOnError
method.readInt
in interface acm.io.IOModel
low
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangepublic final int readInt(String prompt)
setExceptionOnError
method.readInt
in interface acm.io.IOModel
prompt
- The prompt string to display to the userpublic int readInt(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.readInt
in interface acm.io.IOModel
prompt
- The prompt string to display to the userlow
- The lowest value in the permitted rangehigh
- The highest value in the permitted rangepublic final String readLine()
readLine
in interface acm.io.IOModel
String
public String readLine(String prompt)
readLine
in interface acm.io.IOModel
prompt
- The prompt string to display to the userString
public void remove(int index)
public void remove(Component comp)
public void removeAll()
public void removeFromRegion(Component comp, String region)
public void removeMenuBar()
public void removeUpdate(DocumentEvent e)
removeUpdate
in interface DocumentListener
public void repaint()
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 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.run
in interface ProgramInterface
run
in interface Runnable
protected void runHook()
public final void saveConfiguration()
protected void saveConfiguration(Properties props)
public void setAnimated(boolean value)
public void setAnimationDelay(int delayMS)
delayMS
- delay in milliseconds (must be a positive integer)protected void setAppletStub(AppletStub stub)
stub
- The applet stubpublic void setBackground(Color color)
setBackground
in class Component
color
- The new background colorpublic void setBottomY(double y)
y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setCenterX(double x)
x
- the x location as a pixel offset (will be rounded down to nearest integer)public void setCenterY(double y)
y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setCenterLocation(double x, double y)
x
- the x location as a pixel offset (will be rounded down to nearest integer)y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setConsole(IOConsole console)
console
- The IOConsole
object used for this programpublic void setDialog(acm.io.IODialog dialog)
dialog
- The IODialog
object used for this programpublic void setExitOnClose(boolean exitOnClose)
public void setFramesPerSecond(int fps)
fps
- frames per second (must be a non-negative integer)public void setHeight(double height)
height
- the new height, in pixels (will be rounded down to nearest integer)public void setInputModel(acm.io.IOModel io)
io
- The input model used for this programpublic void setInvisible(GObject obj, boolean invisible)
public void setJFrame(JFrame jframe)
jframe
- public void setJMenuBar(JMenuBar bar)
setJMenuBar
in class JApplet
public void setLayout(LayoutManager layout)
public void setLocation(double x, double y)
x
- the x location as a pixel offset (will be rounded down to nearest integer)y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setLocation(GPoint point)
x
- the x location as a pixel offset (will be rounded down to nearest integer)y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setOutputColor(Color color)
public void setOutputModel(acm.io.IOModel io)
io
- The IOModel
object used as the output modelpublic void setParameter(String name, String value)
name
- The name of the parametervalue
- The new valuepublic void setParameterTable(Map<String,String> ht)
setParameterTable
in interface ProgramInterface
ht
- The parameter tablepublic void setPauseScaleFactor(double factor)
public void setResizable(boolean resizable)
title
- The title for this programpublic void setRightX(double x)
x
- the x location as a pixel offset (will be rounded down to nearest integer)public void setShowPixelGrid(boolean show)
public void setShowPixelInfo(boolean show)
public void setSize(double width, double height)
width
- the new width, in pixels (will be rounded down to nearest integer)height
- the new height, in pixels (will be rounded down to nearest integer)public void setStartupObject(Object obj)
getStartupObject
.setStartupObject
in interface ProgramInterface
obj
- The startup objectpublic void setTitle(String title)
setTitle
in interface ProgramInterface
title
- The title for this programpublic void setWidth(double width)
width
- the new width, in pixels (will be rounded down to nearest integer)public void setX(double x)
x
- the x location as a pixel offset (will be rounded down to nearest integer)y
- the y location as a pixel offset (will be rounded down to nearest integer)public void setY(double y)
y
- the y location as a pixel offset (will be rounded down to nearest integer)public void showErrorMessage(String msg)
showErrorMessage
in interface acm.io.IOModel
msg
- The error msg to be displayedpublic final void start()
start
method in Applet
and therefore
will be called as part of applet startup.start
in interface ProgramInterface
start
in class Applet
public void start(String[] args)
start
in interface ProgramInterface
args
- An array of strings passed to the programpublic void startAnimation()
protected void startHook()
protected void startRun()
public void stateChanged(ChangeEvent event)
stateChanged
in interface ChangeListener
public void stopAnimation()
public void textValueChanged(TextEvent e)
textValueChanged
in interface TextListener
public void validate()
public void windowActivated(WindowEvent event)
windowActivated
in interface WindowListener
public void windowClosed(WindowEvent event)
windowClosed
in interface WindowListener
public void windowClosing(WindowEvent event)
windowClosing
in interface WindowListener
public void windowDeactivated(WindowEvent event)
windowDeactivated
in interface WindowListener
public void windowDeiconified(WindowEvent event)
windowDeiconified
in interface WindowListener
public void windowGainedFocus(WindowEvent e)
windowGainedFocus
in interface WindowFocusListener
public void windowIconified(WindowEvent event)
windowIconified
in interface WindowListener
public void windowLostFocus(WindowEvent e)
windowLostFocus
in interface WindowFocusListener
public void windowOpened(WindowEvent event)
windowOpened
in interface WindowListener
public void windowStateChanged(WindowEvent e)
windowStateChanged
in interface WindowStateListener
public static void main(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 arguments