All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cs101.canvas.CS101Canvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----cs101.canvas.CS101Canvas

public class CS101Canvas
extends Panel

Variable Index

 o container

Constructor Index

 o CS101Canvas()
Creates a new CS101Canvas in a new window with a white background.
 o CS101Canvas(Color)
Creates a new CS101Canvas in a new window.
 o CS101Canvas(Container)
Creates a new CS101Canvas with a white background.
 o CS101Canvas(Container, Color)
Creates a new CS101Canvas.

Method Index

 o add(GraphicsObject)
Add a GraphicsObject to the drawing surface
 o addClickListener(ClickListener)
Register a ClickLister to be informed of mouse clicks
 o addDragListener(DragListener)
Register a DragLister to be informed of mouse drag
 o addMotionListener(MotionListener)
Register a MotionLister to be informed of mouse motion
 o addReleaseListener(ReleaseListener)
Register a ReleaseLister to be informed of mouse release events
 o click()
Interactively wait for the user to click the mouse
in the drawing surface when method is called
 o getCanvasSize()
Get the dimensions of the drawing surface
 o getHeight()
Get the height of the drawing surface
 o getWidth()
Get the width of the drawing surface
 o moveToBack(GraphicsObject)
Moves the object to the back of the picture.
 o moveToFront(GraphicsObject)
Moves the object to the front of the picture.
 o remove(GraphicsObject)
Remove a GraphicsObject from the drawing surface
 o removeClickListener(ClickListener)
Unregister a ClickLister
 o removeDragListener(DragListener)
Unregister a DragLister
 o removeMotionListener(MotionListener)
Unregister a MotionLister
 o removeReleaseListener(ReleaseListener)
Unregister a ReleaseLister
 o setInstruction(String)
Sets the text in the instruction text field.
 o setLabel1(String)
Sets the text in the first label
 o setLabel2(String)
Sets the text in the second label
 o setLabelText1(String)
Sets the text in the first text field
 o setLabelText2(String)
Sets the text in the second text field
 o setStatus(String)
 o sleep(int)
Suspend current thread for a time

Variables

 o container
 protected Container container

Constructors

 o CS101Canvas
 public CS101Canvas()
Creates a new CS101Canvas in a new window with a white background.

 o CS101Canvas
 public CS101Canvas(Color background)
Creates a new CS101Canvas in a new window.

Parameters:
background - Color to set as background
 o CS101Canvas
 public CS101Canvas(Container container)
Creates a new CS101Canvas with a white background.

Parameters:
container - Container to put the new Canvas in
 o CS101Canvas
 public CS101Canvas(Container container,
                    Color background)
Creates a new CS101Canvas.

Parameters:
container - Container to put the new Canvas in
background - Color to set as background

Methods

 o setStatus
 public void setStatus(String s)
 o getCanvasSize
 public Rectangle getCanvasSize()
Get the dimensions of the drawing surface

Returns:
Rectangle object with dimensions
 o getWidth
 public int getWidth()
Get the width of the drawing surface

Returns:
int width of canvas
 o getHeight
 public int getHeight()
Get the height of the drawing surface

Returns:
int height of canvas
 o add
 public void add(GraphicsObject gob)
Add a GraphicsObject to the drawing surface

Parameters:
gob - Reference to GraphicsObject
Returns:
none
 o remove
 public void remove(GraphicsObject gob)
Remove a GraphicsObject from the drawing surface

Parameters:
gob - Reference to GraphicsObject
Returns:
none
 o moveToFront
 public void moveToFront(GraphicsObject gob)
Moves the object to the front of the picture.

 o moveToBack
 public void moveToBack(GraphicsObject gob)
Moves the object to the back of the picture.

 o setInstruction
 public void setInstruction(String text)
Sets the text in the instruction text field.

Parameters:
text - Text to be set
Returns:
none
 o setLabel1
 public void setLabel1(String text)
Sets the text in the first label

Parameters:
text - Text to be set
Returns:
none
 o setLabel2
 public void setLabel2(String text)
Sets the text in the second label

Parameters:
text - Text to be set
Returns:
none
 o setLabelText1
 public void setLabelText1(String text)
Sets the text in the first text field

Parameters:
text - Text to be set
Returns:
none
 o setLabelText2
 public void setLabelText2(String text)
Sets the text in the second text field

Parameters:
Text - to be set
Returns:
none
 o click
 public Position click()
Interactively wait for the user to click the mouse
in the drawing surface when method is called

Returns:
A Position where the user clicked
 o addMotionListener
 public void addMotionListener(MotionListener x)
Register a MotionLister to be informed of mouse motion

Returns:
none
 o removeMotionListener
 public void removeMotionListener(MotionListener x)
Unregister a MotionLister

Returns:
none
 o addDragListener
 public void addDragListener(DragListener x)
Register a DragLister to be informed of mouse drag

Returns:
none
 o removeDragListener
 public void removeDragListener(DragListener x)
Unregister a DragLister

Returns:
none
 o addClickListener
 public void addClickListener(ClickListener x)
Register a ClickLister to be informed of mouse clicks

Returns:
none
 o removeClickListener
 public void removeClickListener(ClickListener x)
Unregister a ClickLister

Returns:
none
 o addReleaseListener
 public void addReleaseListener(ReleaseListener x)
Register a ReleaseLister to be informed of mouse release events

Returns:
none
 o removeReleaseListener
 public void removeReleaseListener(ReleaseListener x)
Unregister a ReleaseLister

Returns:
none
 o sleep
 public static void sleep(int milliseconds)
Suspend current thread for a time

Parameters:
milliseconds - number of milliseconds to sleep
Returns:
none

All Packages  Class Hierarchy  This Package  Previous  Next  Index