Hi there,
I'm trying to figure out how to solve a problem with a Whiteboard project. The program comes with several tools to use. As with any drawing app you have a toolbar with buttons that represent each tool. One for making circles, one for making rectangles, etc. One of those buttons is the SelectTool. The select tool uses mouse movements to determine where your cursor is all the time on the Whiteboard, which is really just a JPanel.
class WhiteBoard extend JPanel{...}
The SelectTool is also used to allow the user to select objects on the whiteboard. When I use it to select ordinary Shape objects, I make the cursor change to Cursor.MOVE_CURSOR if it hovers over an object so that the user knows he can possibly move it. So far so good.
The problem lies in the fact that I've introduced to the whiteboard the ability to add Components. Obviously Components aren't Shape objects. So what I wound up doing is wrapping the desired component (in this case, a JTextArea) into a class that implements the Shape interface. This works, but introduces another problem. Now, when using the SelectTool, I move the cursor over any component the mouseMoved(MouseEvent e) method stops reading the Points on the whiteboard. Here is the critical portion of the method:
So, the question is, how does one make the SelectTool continue to read the Points from the Whiteboard even though the cursor begins hovering over a component? What's frustrating is that the particular Component I'm using is a JTextArea and everytime the cursor hovers over it it gets the focus and the caret starts blinking waiting for user input. That's not what I want when the program is in Select mode. When I place the cursor over an object, regardless of what it is, I want the cursor to change to Cursor.MOVE_CURSOR so that the user knows he can move the object around the whiteboard.
Please advise if you've had to tackle a similar problem,
Alan