objectdraw
Class AWTWindowController

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 objectdraw.AWTController
                      extended by objectdraw.AWTWindowController
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
AWTFrameWindowController

public class AWTWindowController
extends AWTController

AWTWindowController is an AWT compatible class designed to be extended to produce programs that handle simple mouse events and draw graphics in a single window on the screen. In a program written by extending this class, the instructions to be executed in response to various mouse events are placed in the bodies of the methods onMousePress, onMouseRelease, onMouseClick, onMouseMove, onMouseDrag, onMouseEnter, and onMouseExit. Each of these methods is passed a Location describing the location of the mouse at the time of the event. As in the AWTController class, initialization code can be placed in the body of the definition of a begin method. Throughout the definition of a class that extends AWTWindowController, the name "canvas" can be used to refer to the program's DrawingCanvas.

Version:
1.1.1 released February 2005
See Also:
AWTController, AWTFrameWindowController, WindowController, Serialized Form

Nested Class Summary
 
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
protected  DrawingCanvas canvas
          The canvas that the program creates automatically.
 
Fields inherited from class objectdraw.AWTController
DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH
 
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
AWTWindowController()
           
 
Method Summary
 void begin()
          Programs written by extending AWTController can perform any required initialization by defining a begin method containing the code to perform the initialization steps.
(package private)  boolean callBegin()
          Checks to see if the Canvas' Graphics is not null and the Canvas has size.
 void init()
          Initializes the program by creating a window containing a canvas and invoking the user supplied begin method.
 void onMouseClick(Location point)
          Invoked when the mouse has been clicked on the WindowController's canvas.
 void onMouseDrag(Location point)
          Invoked when a mouse button is pressed on a component and then dragged.
 void onMouseEnter(Location point)
          Invoked when the mouse enters the WindowController's canvas.
 void onMouseExit(Location point)
          Invoked when the mouse exits the WindowController's canvas.
 void onMouseMove(Location point)
          Invoked when the mouse button has been moved on the WindowController's canvas (with no buttons depressed).
 void onMousePress(Location point)
          Invoked when a mouse button has been pressed on the WindowController's canvas.
 void onMouseRelease(Location point)
          Invoked when a mouse button has been released on the WindowController's canvas.
 
Methods inherited from class objectdraw.AWTController
destroy, getAudio, getImage, placeInFrame, resize, setup, start, startController, startController, stop
 
Methods inherited from class java.applet.Applet
getAccessibleContext, 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, addImpl, 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, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, 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, getGraphics, 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, 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

canvas

protected DrawingCanvas canvas
The canvas that the program creates automatically.

Constructor Detail

AWTWindowController

public AWTWindowController()
Method Detail

begin

public void begin()
Description copied from class: AWTController
Programs written by extending AWTController can perform any required initialization by defining a begin method containing the code to perform the initialization steps.

Overrides:
begin in class AWTController

callBegin

boolean callBegin()
Checks to see if the Canvas' Graphics is not null and the Canvas has size. If it does, it calls Controller's callBegin method, otherwise, it returns.

Overrides:
callBegin in class AWTController
Returns:
tells whether begin was called

init

public void init()
Initializes the program by creating a window containing a canvas and invoking the user supplied begin method. Programmers extending this class should not include their own definition of init.

Overrides:
init in class AWTController

onMouseClick

public void onMouseClick(Location point)
Invoked when the mouse has been clicked on the WindowController's canvas.

Parameters:
point - the point the mouse clicked on

onMouseDrag

public void onMouseDrag(Location point)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the controller first originated until the mouse button is released (regardless of whether the mouse position remains within the bounds of the canvas).

Parameters:
point - the point the mouse drags

onMouseEnter

public void onMouseEnter(Location point)
Invoked when the mouse enters the WindowController's canvas.

Parameters:
point - the point the mouse enters

onMouseExit

public void onMouseExit(Location point)
Invoked when the mouse exits the WindowController's canvas.

Parameters:
point - the point the mouse exits

onMouseMove

public void onMouseMove(Location point)
Invoked when the mouse button has been moved on the WindowController's canvas (with no buttons depressed).

Parameters:
point - the point the mouse moves

onMousePress

public void onMousePress(Location point)
Invoked when a mouse button has been pressed on the WindowController's canvas.

Parameters:
point - the point the mouse pressed on

onMouseRelease

public void onMouseRelease(Location point)
Invoked when a mouse button has been released on the WindowController's canvas.

Parameters:
point - the point the mouse released on