|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.event.MouseInputAdapter
Graphics2DTestPlusUserDrawing.RectDrawingListener
Class RectDrawingListener extends JFC's MouseInputAdpater to provide handlers for three mouse events: mouse pressed, mouse dragged, and mouse released. The comments for the event-handling methods describe in detail what each method does to allow the user to draw rectangles.
The general drawing strategy is to add and remove rectangles from the canvas shapeList as the mouse is being dragged, repainting the canvas at each addition. Since repainting is done efficiently by JFC, this technique is visually OK even if the canvas shapeList contains a large number of other rectangles to be drawn.
Constructor Summary | |
Graphics2DTestPlusUserDrawing.RectDrawingListener()
|
Method Summary | |
void |
mouseDragged(java.awt.event.MouseEvent e)
Remove the previously drawn rect and add a new one that extends from the starting point to the current mouse position. |
void |
mousePressed(java.awt.event.MouseEvent e)
Record the initial mouse press as the starting point of the rectangle to be drawn. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Remove the previously drawn rect and add a new rect in its final position. |
Methods inherited from class javax.swing.event.MouseInputAdapter |
mouseClicked, mouseEntered, mouseExited, mouseMoved |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Graphics2DTestPlusUserDrawing.RectDrawingListener()
Method Detail |
public void mousePressed(java.awt.event.MouseEvent e)
public void mouseDragged(java.awt.event.MouseEvent e)
public void mouseReleased(java.awt.event.MouseEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |