Class ImageCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----ImageCanvas

public class ImageCanvas
extends Canvas

ImageCanvas is a Canvas that holds an Image. The Image can be switched, but ImageCanvas assumes all Images have the same dimensions of the first image.


Constructor Index

 o ImageCanvas()
This is provided for convenience only.
 o ImageCanvas(ImageCanvasEventHandler, Image)
Creates an ImageCanvas with the specified event handler and initial image.

Method Index

 o draw()
Draws the ImageCanvas
 o minimumSize()
 o mouseDown(Event, int, int)
Handles a mouseDown event by calling the ImageCanvas' callback (set in the constructor).
 o mouseUp(Event, int, int)
Doesn't do anything right now
 o paint(Graphics)
 o preferredSize()
 o setImage(Image)
Sets the ImageCanvas to a new Image.

Constructors

 o ImageCanvas
 public ImageCanvas()
This is provided for convenience only. ImageCanvas objects must be initialized by calling a constructor that has parameters.

 o ImageCanvas
 public ImageCanvas(ImageCanvasEventHandler handler,
                    Image image)
Creates an ImageCanvas with the specified event handler and initial image.

Parameters:
handler - a callback function that handles events generated by this ImageCanvas
Image - initial Image to be displayed. All subsequent Images set with setImage should have the same dimensions.

Methods

 o preferredSize
 public Dimension preferredSize()
Overrides:
preferredSize in class Component
 o minimumSize
 public Dimension minimumSize()
Overrides:
minimumSize in class Component
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Canvas
 o draw
 public void draw()
Draws the ImageCanvas

 o setImage
 public void setImage(Image image)
Sets the ImageCanvas to a new Image. This should have the same dimensions as the initial Image.

 o mouseDown
 public boolean mouseDown(Event event,
                          int x,
                          int y)
Handles a mouseDown event by calling the ImageCanvas' callback (set in the constructor).

Overrides:
mouseDown in class Component
 o mouseUp
 public boolean mouseUp(Event event,
                        int x,
                        int y)
Doesn't do anything right now

Overrides:
mouseUp in class Component