objectdraw
Class Controller

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 objectdraw.Controller
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer
Direct Known Subclasses:
FrameController, WindowController

public class Controller
extends JApplet

Controller is a Swing compatible class designed to be extended to produce programs that employ a GUI but do not include graphics displayed in a DrawingCanvas. To write such a program, a programmer should extend this class defining a begin method that performs initialization, including constructing the programs GUI, appropriate instance variable, and any private methods needed to simplify the definition of the begin method or to handle GUI events.

Version:
1.1.1 released February 2005 Version 1.1 added getVersion static method
See Also:
AWTController, WindowController, 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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
(package private) static int DEFAULT_WINDOW_HEIGHT
           
(package private) static int DEFAULT_WINDOW_WIDTH
          default sizes for Controller window when run outside an applet viewer
 
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
Controller()
           
 
Method Summary
 void begin()
          Programs written by extending Controller can perform any required initialization by defining a begin method containing the code to perform the initialization steps.
 void destroy()
          This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program's execution is complete.
 AudioClip getAudio(String path)
          Retrieves an audio file
 Image getImage(String path)
          Retrieves an image.
static String getVersion()
          Determine the version of the objectdraw library being used.
protected  void helpinit()
           
 void init()
          This predefined method is invoked by the applet viewer or web browser used to run a program that extends Controller to initiate the execution of the program.
 void placeInFrame(int width, int height)
          Associate of this controller with an independent window.
 void resize(int width, int height)
          Resize the window in which this controller is running (if possible)
protected  void setup()
          Initialization common to Controllers and WindowControllers.
 void start()
          This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program should commence or resume active execution.
 void startController()
          Run this controller in an independent window of default size.
 void startController(int width, int height)
          Run this controller in an independent window of the specified size.
 void stop()
          This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program should cease active execution.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, setStub, showStatus
 
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, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, 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, revalidate, setBackground, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WINDOW_HEIGHT

static final int DEFAULT_WINDOW_HEIGHT
See Also:
Constant Field Values

DEFAULT_WINDOW_WIDTH

static final int DEFAULT_WINDOW_WIDTH
default sizes for Controller window when run outside an applet viewer

See Also:
Constant Field Values
Constructor Detail

Controller

public Controller()
Method Detail

begin

public void begin()
Programs written by extending Controller can perform any required initialization by defining a begin method containing the code to perform the initialization steps.


destroy

public final void destroy()
This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program's execution is complete. It ensures that all ActiveObjects that have been created by the program are notified that they should cease execution. Programmers extending this class should not include their own definition of destroy.

Overrides:
destroy in class Applet

getAudio

public AudioClip getAudio(String path)
Retrieves an audio file

Parameters:
path - the file path name or URL of the desired audio file
Returns:
the requested audio file

getImage

public Image getImage(String path)
Retrieves an image.

Parameters:
path - the file path name or URL of the desired image.
Returns:
the requested image

getVersion

public static String getVersion()
Determine the version of the objectdraw library being used.

Returns:
a String describing the version of the library

helpinit

protected void helpinit()

init

public final void init()
This predefined method is invoked by the applet viewer or web browser used to run a program that extends Controller to initiate the execution of the program. Programmers extending this class should not include their own definition of init.

Overrides:
init in class Applet

placeInFrame

public void placeInFrame(int width,
                         int height)
Associate of this controller with an independent window. This is used when a controller is executed as an application or under a development environment like BlueJ or DrJava. If this method is used, the invoker must later ensure that the Controller's init and begin methods are invoked to initiate execution.

Parameters:
width - the width of the desired window
height - the height of the desired window

resize

public void resize(int width,
                   int height)
Resize the window in which this controller is running (if possible)

Overrides:
resize in class Applet
Parameters:
width - the new width for the window
height - the new height for the window

setup

protected void setup()
Initialization common to Controllers and WindowControllers.


start

public final void start()
This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program should commence or resume active execution. It ensures that all ActiveObjects that have been created by the program are notified that the program has been started. Programmers extending this class should not include their own definition of start.

Overrides:
start in class Applet

startController

public void startController()
Run this controller in an independent window of default size. This is used when a controller is executed as an application or under a development environment like BlueJ or DrJava. For example, the main method of an application that extends AWTController would typically consist of a single command that invoked runInFrame.


startController

public void startController(int width,
                            int height)
Run this controller in an independent window of the specified size. This is used when a controller is executed as an application or under a development environment like BlueJ or DrJava. For example, the main method of an application that extends AWTController would typically consist of a single command that invoked runInFrame.

Parameters:
width - the width of the desired window
height - the height of the desired window

stop

public final void stop()
This predefined method is invoked by the appletviewer or web browser running a program that extends Controller when the program should cease active execution. This may happen because the window in which the program is executing is temporarily hidden from view. In this case, the program's execution may later be resumed by an invocation of the start method. The stop method ensures that all ActiveObjects that have been created by the program are notified that the program has been suspended. Programmers extending this class should not include their own definition of stop.

Overrides:
stop in class Applet