Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Register MouseListener's mouseExited to JDialog or JFrame  RSS feed

 
Miro Ricco
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I would like to hide the JFrame automatically when the mouse exits its boundary.
I have registered mouse listener to JFrame, but mouseExited method is never called.
What is wrong?
I use Java 6.

It is working in empty frame or if there is only a panel.
But try to add JTabbedPane and it stops working.

My code:


From java.awt.event.MouseEvent javadoc:
An event which indicates that a mouse action occurred in a component. A mouse action is considered to occur in a particular component if and only if the mouse cursor is over the unobscured part of the component's bounds when the action happens. "Component bounds can be obscurred by the visible component's children or by a menu or by a top-level window."

Does it mean it is not possible to catch mouse exit of the frame?
Because it always contains some components...
 
Miro Ricco
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the Glass pane is a feature of a frame which could be used for this.
It works very well for mouse exit, but on the other side it has other problems.
I've modified the glass pane demo to propagate all the events to other components, but it has these problems:

1) When the glassPane is visible, there are no rollover effects on the buttons or checkboxes.
2) When the glassPane is visible, press down on a button, then drag the mouse away from the button, and release it. the button stays depressed.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!