Class Graphics2DTestPlusUserDrawing

java.lang.Object
  extended byGraphics2DTest
      extended byGraphics2DTestPlusUserDrawing
Direct Known Subclasses:
Graphics2DTestPlusGlassPane

public class Graphics2DTestPlusUserDrawing
extends Graphics2DTest

This is an extension of the Graphics2DTest example that illustrates how to let the user draw rectangles on the canvas by dragging the mouse. As the user drags the mouse, the rectangle dynamically tracks the mouse movements. The inner class RectDrawingListener is the interesting part.


Nested Class Summary
static class Graphics2DTestPlusUserDrawing.RectDrawingListener
          Class RectDrawingListener extends JFC's MouseInputAdpater to provide handlers for three mouse events: mouse pressed, mouse dragged, and mouse released.
static class Graphics2DTestPlusUserDrawing.RectShapeUserDrawn
          Specialization of the RectShape class used to distinguish user-drawn rectangles from the fixed-shape rectangles added when the `Delete Rect' button is pressed.
 
Nested classes inherited from class Graphics2DTest
Graphics2DTest.DrawingCanvas, Graphics2DTest.MousePressedListener, Graphics2DTest.RectShape
 
Field Summary
protected static int startX
          The starting x-axis position for the drawn rectangle
protected static int startY
          The starting y-axis position for the drawn rectangle
 
Fields inherited from class Graphics2DTest
addButton, buttonBox, canvas, delButton, frame, numButton, shapeList, vbox, x, y
 
Constructor Summary
Graphics2DTestPlusUserDrawing()
           
 
Method Summary
static void changeDeleteButtonListener()
          Change the action listener for the `Delete Rect' button so it does not decrement the x,y positions for the fixed rects if the rect being deleted is one that was drawn by the user.
static void main(java.lang.String[] args)
          Call the parent compose method and the local button listener change method.
 
Methods inherited from class Graphics2DTest
addButtonListeners, compose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startX

protected static int startX
The starting x-axis position for the drawn rectangle


startY

protected static int startY
The starting y-axis position for the drawn rectangle

Constructor Detail

Graphics2DTestPlusUserDrawing

public Graphics2DTestPlusUserDrawing()
Method Detail

changeDeleteButtonListener

public static void changeDeleteButtonListener()
Change the action listener for the `Delete Rect' button so it does not decrement the x,y positions for the fixed rects if the rect being deleted is one that was drawn by the user.


main

public static void main(java.lang.String[] args)
Call the parent compose method and the local button listener change method. Then add a new RectDrawingListener to the canvas.