java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
objectdraw.Controller
objectdraw.WindowController
public class WindowController
WindowController
in the class that defines how you interact with the drawing
canvas of your program. It has methods that will be called when the program is first run,
and then when various mouse and keyboard events occur, and in those methods you can use the
canvas
variable, inherited from WindowController
, to draw objects
on the canvas.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JApplet |
---|
JApplet.AccessibleJApplet |
Nested classes/interfaces inherited from class java.applet.Applet |
---|
Applet.AccessibleApplet |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected DrawingCanvas |
canvas
In a class extending WindowController , you can use the canvas
variable to refer to the canvas of that controller. |
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 | |
---|---|
WindowController()
Construct a new WindowController. |
Method Summary | |
---|---|
void |
begin()
This method is called when the applet first appear on the screen. |
DrawingCanvas |
getCanvas()
Retrieve the canvas object of this WindowController . |
void |
onMouseClick(Location point)
This method is called when the user clicks on the canvas - that is, presses and releases the mouse without dragging it in between. |
void |
onMouseDrag(Location point)
This method is called as the user is dragging the mouse across the canvas - that is, moving the mouse with the button held down. |
void |
onMouseEnter(Location point)
This method is called when the mouse enters the canvas. |
void |
onMouseExit(Location point)
This method is called when the mouse leaves the canvas. |
void |
onMouseMove(Location point)
This method is called as the user is moving the mouse across the canvas without the mouse button held down. |
void |
onMousePress(Location point)
This method is called when the mouse button is pressed. |
void |
onMouseRelease(Location point)
This method is called when the mouse button is released. |
Methods inherited from class objectdraw.Controller |
---|
getAudio, getImage, getVersion, hideGrid, isGridVisible, showGrid, startController, startController, startController |
Methods inherited from class javax.swing.JApplet |
---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
Methods inherited from class java.applet.Applet |
---|
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
Methods inherited from class java.awt.Panel |
---|
addNotify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected DrawingCanvas canvas
WindowController
, you can use the canvas
variable to refer to the canvas of that controller.
Constructor Detail |
---|
public WindowController()
Method Detail |
---|
public void begin()
begin
in class Controller
public DrawingCanvas getCanvas()
canvas
object of this WindowController
.
WindowController
's canvas.public void onMouseClick(Location point)
point
- Location
of the mousepublic void onMouseDrag(Location point)
point
- Location
of the mousepublic void onMouseEnter(Location point)
point
- Location
of the mousepublic void onMouseExit(Location point)
point
- Location
of the mousepublic void onMouseMove(Location point)
point
- Location
of the mousepublic void onMousePress(Location point)
point
- Location
of the mousepublic void onMouseRelease(Location point)
point
- Location
of the mouse