Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jwindow, jscrollpane and jtable + mouse cursor

 
mark goking
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jwindow that contains a jscrollpane that contains a jtable.

what i want to do is to trigger the jwindow to close when the mouse cursor is not on top of it

i added a mouselistener to the jscrollpane but the method does not get called consistently

this is how i did it


i added +20 to the width of the rectangle to include the jscrollpane's jscrollbar's width

any ideas what i could be doing wrong? thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this feels far from a good solution, but it seems to work OK (for now)

 
mark goking
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks michael , that worked!

i tried to add the addAWTEventListener() but there is no such method available for JScrollPane

the jframe is actually the main root window

and there is a button in it, when clicked, the jwindow pops up and that is where id like the jwindow to be hidden if the mouse cursor is not on top of it anymore.

any ideas?

thanks!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> i tried to add the addAWTEventListener() but there is no such method available for JScrollPane

it's a global listener, added to the toolkit - run the code, then move the pointer between the scrollpane
and the button, and back again - multiple mouseExited's fire


> and there is a button in it, when clicked, the jwindow pops up and that is where id like the jwindow to be hidden if the mouse cursor is not on top of it anymore.

the code should work for the above - basically when an exited is fired, a time delay (150ms), then the code checks if the current pointer position
is within the rectangle returned from window.getBounds()

may have to modify to add a check if the window is visible/showing
 
mark goking
Ranch Hand
Posts: 155
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got to modify your code to make it work

thanks a lot michael!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic