Handle JMenuBar with visible glass pane

Discussion in 'Java' started by Simon Niederberger, May 18, 2004.

  1. 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
    Simon Niederberger, May 18, 2004
    #1
    1. Advertising

  2. Here's a Java Forum entry which might help:

    http://forum.java.sun.com/thread.jsp?thread=208887&forum=57&message=1431994

    "Simon Niederberger" <> wrote in message
    news:40aa7818$...
    > 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
    >
    >
    Simon Niederberger, May 19, 2004
    #2
    1. Advertising

  3. Simon Niederberger

    ak Guest

    > 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

    --
    http://uio.dev.java.net
    http://reader.imagero.com
    ak, May 19, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Cant make Calendar visible within Pane!

    VB Programmer, Aug 23, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    338
    VB Programmer
    Aug 23, 2004
  2. Ajay

    JMenuBar and JPanel

    Ajay, Sep 23, 2005, in forum: Java
    Replies:
    1
    Views:
    15,626
  3. BugFree
    Replies:
    2
    Views:
    924
    BugFree
    Apr 23, 2006
  4. Patrick.O.Ige
    Replies:
    0
    Views:
    753
    Patrick.O.Ige
    Aug 31, 2006
  5. Amiro

    IE search pane - handle close event

    Amiro, Apr 10, 2006, in forum: Javascript
    Replies:
    0
    Views:
    127
    Amiro
    Apr 10, 2006
Loading...

Share This Page