I have an application having five buttons:
i) Square ii) Rectangle iii) Circle iv) Triangle v) Clear
Clicking on any of the first four buttons will draw a shape on a drawing canvas (which is a JPanel).
Now the shapes drawn are stored in an ArrayList called Shapes. Now, I want to let the user click on any shape and drag it on the screen.
This is how my project is organized in terms of classes:
i) Square ii) Rectangle iii) Circle iv) Triangle v) Drawing Canvas (for the JPanel where the shapes are drawn) vi) Application (for the User Interface)
This is what I have done so far:
The first method checks whether the mouse cursor is inside the drawn shape. The second method draws the square.
The above mouse event handlers are supposed to drag the shape on the canvas. However, the shapes are not being dragged. How can I solve this problem please?
Note
The shapes are added to the arraylist correctly as they are drawn when clicking on any of the four buttons. What does not work is the dragging.