wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes selecting Components on whiteboard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "selecting Components on whiteboard" Watch "selecting Components on whiteboard" New topic

selecting Components on whiteboard

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
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,

sekhar babu

Joined: Sep 07, 2007
Posts: 1
hi i have worked on whiteboard application
you can send the code you have developed.
i will try to rectify it.
and i will send my code also.it will help you.
my mail id : unsekhable@gmail.com
I agree. Here's the link: http://aspose.com/file-tools
subject: selecting Components on whiteboard
jQuery in Action, 3rd edition