Class DrawingPanel
java.lang.Object
DrawingPanel
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.util.EventListener
public class DrawingPanel
- extends java.lang.Object
- implements java.awt.event.ActionListener
The DrawingPanel class provides a simple interface for drawing persistent
images using a Graphics object. An internal BufferedImage object is used
to keep track of what has been drawn. A client of the class simply
constructs a DrawingPanel of a particular size and then draws on it with
the Graphics object, setting the background color if they so choose.
To ensure that the image is always displayed, a timer calls repaint at
regular intervals.
- Author:
- Stuart Reges, Marty Stepp
|
Constructor Summary |
DrawingPanel(int width,
int height)
|
DrawingPanel(int width,
int height,
java.lang.String panelTitle)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DrawingPanel
public DrawingPanel(int width,
int height)
DrawingPanel
public DrawingPanel(int width,
int height,
java.lang.String panelTitle)
addKeyListener
public void addKeyListener(java.awt.event.KeyListener listener)
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed in interface java.awt.event.ActionListener
getGraphics
public java.awt.Graphics2D getGraphics()
setBackground
public void setBackground(java.awt.Color c)
setVisible
public void setVisible(boolean visible)
sleep
public void sleep(int millis)
close
public void close()
toFront
public void toFront()
getWidth
public int getWidth()
getHeight
public int getHeight()
getMouseX
public int getMouseX()
getMouseY
public int getMouseY()
getClickX
public int getClickX()
getClickY
public int getClickY()
mousePressed
public boolean mousePressed()