posted 19 years ago
This is another approach that uses two JPanels in an OverlayLayout. The lower panel(DrawingPanel) is for drawing. The upper panel (TopPanel) has the mouse listeners registered on it. When you mousePress on the image (JLabel in the north section) the image is transferred to TopPanel where it follows the mouse until the next mousePress when it is transfered to (imageList) DrawingPanel.
A mousePress on the panel, vis–a–vis the image label, initiates dragging and the drawing of a new Rectangle that is added to the DrawingPanel state (shapeList) after mouseRelease.
The ImageStore class is a DataStore to keep track of images and their location for rendering in DrawingPanel.