Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JMenu setPopupMenuVisible not working?

843806Nov 1 2007 — edited Nov 2 2007
Hello everyone,


I am trying to hide the popup menu of a JMenu on a JFrame but setPopupMenuVisible(false) seems not to work.

Maybe I haven't got the true meaning of this function. This is the code, nothing special:

jMenuBar = new javax.swing.JMenuBar();
jMenu = new javax.swing.JMenu();
jMenuItem = new javax.swing.JMenuItem();
jMenuItem.setText("Item");
jMenu.setText("Menu");
jMenu.setPopupMenuVisible(false);
jMenu.add(jMenuItem);
jMenuBar.add(jMenu);
setJMenuBar(jMenuBar);

The thing is, with an empty JMenu, there is a small grey area under the JMenu-button still showing. That is very annoying. I am using JDK 1.6.

The only workaround that I have found is this:

jMenu.getPopupMenu().setPopupSize(0,0);

Is this a bug or something normal? What about that little grey area?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2007
Added on Nov 1 2007
2 comments
122 views