I’m attempting to implement the dragging functionality of shapes on a canvas. My Shape class inherits from JPanel.
Absolutely nothing happens when I click on a shape, drag it and let go of the mouse button. It just remains where it was originally. Any ideas?
You need a few basic things:
paintComponentmethod to paint your shapeMouseListenerandMouseMotionListeneradded to the Panel (MouseAdapterdoes both of these)Here’s a basic working example.