I have a simple Java program that allows a user to draw rectangles on a JPanel, then move them around, resize them, and delete them.
The drawing panel implements MouseListener and MouseMotionListener. When an event is triggered, it checks which menu option is selected (new rectangle, move, resize, or delete), and reacts accordingly.
When the 'resize' option is selected, the listener's methods do the following:
MouseMoved calls boolean detectBoundary(). When that returns true, the rectangle to which the boundary belongs is set as the active rectangle.
MouseDragged calls void moveBoundary, which moves the detected boundary in the direction of the dragging gesture.
Now what I am looking for is a way to make the boundary that is going to be moved stand out. I can re-paint the whole rectangle in thicker lines or a different color, which is what I do now when I set a given rectangle as the active one, but that's not what I want. I'd like to re-color just the one boundary.
A setBorder method that can handle BorderFactory's createMatteBorder method would seem to be ideal for these purposes, but I haven't been able to find a way to make that work.
Does anyone here have an idea how I could accomplish this?
All suggestions will be greatly appreciated.