• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

selecting Components on whiteboard

Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic