The most annoying but strangest bug for me in NetBeans is …

Some time ago I developed an QtiPlot or Origin-like application called genvlin with the NetBeans 5.0 platform. Then I discovered a really strange bug under linux with an relative old jdk:

If the user wants to select a menu item e.g. open projects he has to go some menu item below to select this item. It was strange and annoying at the same time, because in NetBeans 5.0 IDE I didn’t see this bug.

Now someone could say: time has changed and no such bug exists in 6.1.

No, thats not true!

Today I discovered exactly the same old and annoying bug in the latest IDE 6.1 (with jdk 1.6.0_06) here I captured a screenshot:

I simulated the mouse pointer with a red dot. In 5.0 it was even worse: the mouse sometimes was several pixels below this point!

I don’t fake it. Believe me! (Does anybody know how to capture screenshot with mouse pointers under linux?) You can trust that I didn’t fake the image, because then I captured another interesting screenshot:

Which might be a solution to the problem: the JPopupMenu (I guess menus are implemented in this manner) is shown at the wrong position.

Has anybody seen the same bug, too??

It is really difficult to reproduce. Sometimes it occures and sometimes not…

E.g. I restarted NetBeans and it disapears.

Please look here for the bug report at netbeans.org.

UPDATE = PARTIAL SOLUTION

Today (19.08.08) it was the first day I see this behaviour in another java application.
(The popupmenu selection was different to the mouse position)
So I guess: its not a netbeans issue!!

UPDATE2

You can stimulate this bug via:

click “restore old size” in the menubar (WindowMaker) of the window of Netbeans -> move the window a bit left (out of screen) -> maximize -> now e.g. right click a project => context menu => bug

17 thoughts on “The most annoying but strangest bug for me in NetBeans is …

  1. I can confirm I’ve seen it a couple of times, but I can’t recall when. In the latest months I’ve never seen it again. One of the things I’ve thought about it is that the problem is some computation about the displacement of the menu bar, because the offset seems to be exactly the menu bar height. But it disappeared (or better, it never happened again) before I could study it better.

  2. Thanks Fabrizio for sharing your thoughts. It is indeed very difficult to study. Restarting and sometimes even only resizing is enough to disappear, but in 5.0 it was more likely to get this behaviour.

    > exactly the menu bar height.

    Oh, yes this could be the point.
    Although in 5.0 it was sometimes twice or even thrice of the shown heigh-offset …

    What I don’t understand: does netbeans use another implementation for the menu bar?
    Because in pure Java apps I have never seen this.

  3. I wonder what window manager you are using. The gap between the menu bar and the menu looks to be the same as the height of the titlebar. I.e. the code in Swing that positions the menu popup thinks the window manager is including the height of the titlebar in the window height the window manager reports, so that code compensates for it by moving the y coordinate down by the height of the titlebar.

    I remember in the days of JDK 1.3 and 1.4 I saw this sort of thing a lot – some window manager had this sort of bug on Sun’s JDK but not on IBMs, and on others vice-versa. I was running Blackbox at the time – there was a general problem of some window managers reporting window dimensions including titlebar height and some not.

    It’s just a guess, but this looks like what’s going on.

    You might try running NetBeans with
    -J-Dawt.toolkit=sun.awt.motif.MToolkit
    or
    -J-Dawt.toolkit=sun.awt.X11.XToolkit

    and see if that helps (I think with 1.5 MToolkit [motif] is the default and with 1.6 XToolkit is the default, but I might be remembering incorrectly.

    -Tim

  4. Hi Tim,

    I am using http://www.windowmaker.info, but the bug (at least with the old netbeans 5.0 platform) appears under kde as well. So, yes windowmaker is not a widely used window manager and this could be the reason …
    But why I never saw this in pure Java applications?

    Thanks for the suggested parameters.
    Do you have any idea how I could force this behavior?
    This bug is somewhat rare and so I couldn’t say if another window manager or your suggested parameters will help.

    @Fabrizio
    Which window manager did you use?

  5. I haven’t used WindowMaker in years, but I suspect it is the culprit, although NB is pure Java and while it does do much futzing with the way in which menus work (lazy initialization and so forth), I used to maintain the main menu code and I don’t know of anything that plays with how the popup is actually displayed or where it’s positioned.

    What JDK, etc. are you using – both version and vendor? I.e. what is the output of java -version for the copy of Java NetBeans is using? (you can also find this under Help | About > Details).

    Did you try the XToolkit/MToolkit line switches and did either help?

    It would probably be worth launching X with a different window manager and see if the problem is reproducible there – that would help confirm if the problem is what I think it is.

    -Tim

  6. I am using sun’s jdk.

    /usr/java/latest/bin/java -version
    java version “1.6.0_06”
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

    > Did you try the XToolkit/MToolkit line switches and did either help?

    No, not yet.
    Reproducing is very difficult as I said. For NetBeans 6.1 this occured only 3 times for now (although I heavily use NetBeans) since it was released.

    > It would probably be worth launching X with a different window manager and see if the
    > problem is reproducible there – that would help confirm if the problem is what I think it is.

    Yes, I would like to help here (would kde be okay?). But again: it is not reproducable, it is only sometimes, very rare.
    Do you think it is worth that I should try my old application again?
    Because I had the feeling that there it was ‘nearly’ reproducable.

    Regards,
    Peter.

  7. Hi.

    I don’t use Window Maker, just the plain installation of Ubuntu, so I think it’s gnome. I must confirm I never saw that problem again in the latest days.

  8. I’m having the same problem with greenfoot (greenfoot.org). In one part of the GUI, the mouse interaction with drop down and contextual menus is heavily shifted. in another part of the GUI, the mouse interaction is right on the contextual menu, but the whole contextual menu is shifted ! looks like someone screwed up big time at Sun …

  9. I have the same bug with windowmaker and netbeans (6.0.1).
    In the beginning all works fine, but when I maximise the window, this bug appears. However, if you just stretch the window (alt+right click), the bug won’t appear.
    So there you go, hope this helps.

  10. Hi Djordje, thanks for the nice shortcut🙂
    But normally I do not maximize windows, because windowmaker does not rember the size.
    So, I always resize the window manually to the maximal size.
    BTW: do you know a better workaround for this??

  11. What do you mean by “does not remember the size”? If you maximize a window and then unmaximize it, il will have the same position and size as before. If that’s what you were talking about.
    The other workaround that works for me is just not no touch the size of the window.🙂

  12. I have often had this problem with jdk 1.6, netbeans 6.x, and windowmaker. I just tried adding -J-Dawt.toolkit=sun.awt.motif.MToolkit to my netbeans.conf and it appears to have resolved the issue. Thanks for the tip.🙂

  13. I have this problem, it happens every time with the latest jdk running the latest netbeans if I run across XWindows. I solved it for a while with -J-Dawt.toolkit=sun.awt.motif.MToolkit but after a reinstall this causes netbeans to crash. This is making netbeans unusable for me. Even if I resize manually it doesnt cure the problem.

    • I have the same problem with WindowMaker with NetBeans 6.8 and Oracle SQL Developer

      Can someone send WindowMaker a bug report so they can fix it.
      I did not see how on their website.

      WindowMaker seems stale. Has not been updated in years😦

  14. This can be a possible solution for the bug, I am on linux mint 12 (ubuntu 11.10) and have installed oracle-jdk-6, oracle-jdk-7u3, openjdk-6, openjdk-7 and the issue can be regeneration if you use oracle(sun) jdk versions on my linux machine, it appeared on both 32bit and 64bit ubuntu versions. So I thought the bug is somehow related to the Linux + OracleJDK + Netbeans combination.

    I managed to fix it by using OpenJDK 6 or OpenJDK 7 on my linux box to power up NetBeans 7. You can change which JDK version assigned to NetBeans on one of the following locations

    If you installed NetBeans through synaptic or whatever package manager, config is at /etc/netbeans/netbeans.conf
    If you have installed it from the binary downloaded from NetBeans.org try /etc/ folder in the installation directory. You will find netbeans.conf

    Edit netbeans_jdkhome to openJDK path.

    On ubuntu releases JDK is installed in /usr/lib/jvm directory.

    Hope this will help someone.

Comments are closed.