Handle JMenuBar with visible glass pane

S

Simon Niederberger

Hi

I'm currently implementing a swing GUI which uses a glass pane. My problem
is with the MouseListener:
I intercept the mouse events on the glass pane, and dispatch events to the
underlying components when necessary. I looked at an example in the Sun Java
forum, where they also use a JMenuBar. Here's my problem:

A mouse click on the JMenuBar is recognized as such, as the y-coordinate of
the event is negative. However, when the menu list (JMenu) is displayed, a
click on a menu item is not dispatched to the JMenuBar, as the coordinates
show to the JPanel just below the menu bar.

Does anyone have a solution to this?

Thanks
Simon

Posted to: comp.lang.java.programmer; comp.lang.java.gui
 
A

ak

I'm currently implementing a swing GUI which uses a glass pane. My problem
is with the MouseListener:
I intercept the mouse events on the glass pane, and dispatch events to the
underlying components when necessary. I looked at an example in the Sun Java
forum, where they also use a JMenuBar. Here's my problem:

A mouse click on the JMenuBar is recognized as such, as the y-coordinate of
the event is negative. However, when the menu list (JMenu) is displayed, a
click on a menu item is not dispatched to the JMenuBar, as the coordinates
show to the JPanel just below the menu bar.

Does anyone have a solution to this?

see http://www.physci.org/codes/sscce.jsp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top