- JMenu in the JDK7 Javadoc
Questions tagged [jmenu]
361 questions
16
votes
3 answers
JMenu ActionListener
I was wondering if can you test to see if a JMenu (not JMenuItem) has been clicked. I tried adding an ActionListener to it but it doesn't seem to recognize it. I just need it to preform an action when the JMenu button is pressed so that I can change…

clankfan1
- 225
- 2
- 3
- 10
15
votes
3 answers
How to make a JMenu item do something when it's clicked
I'm making a GUI that has a Jmenu; it has the jmenu items that will be doing things when clicked. That is the problem. I've looked and looked, but I can't find out how to make it do something when clicked. Also, I am kind of a noob, so if you…

PulsePanda
- 1,806
- 10
- 33
- 56
13
votes
3 answers
Custom JMenuItems in Java
Would it be possible to create a custom JMenuItem that contains buttons? For example would it be possible to create a JMenuITem with an item similar to this:
+----------------------------------------+
| JMenuItem [ Button | Button | Button ]…

Michael
- 577
- 6
- 13
12
votes
1 answer
Swing: creating a checkbox or check symbol in menuItem of jMenu
I want to create a checkbox or check symbol in front of menuItem in a JMenu.
For example, when we open a Notepad file and click on Format menu there is a checkbox in front of Word Wrap menuItem of the Format menu.

Neeraj singh
- 257
- 1
- 8
- 18
8
votes
2 answers
JComboBox on a JPopupMenu
I'm trying to use a compound Swing component as part of a Menu.
Everything works just fine, apart from one detail: The component contains JComboBoxes and whenever the user clicks on one of them to open its dropdown, the dropdown opens but the menu…

Max
- 81
- 2
7
votes
4 answers
Aligning JMenu on the right corner of JMenuBar in Java Swing
So if i have a JMenu & JMenuBar defined such that:
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu1.setText("About");
jMenuBar1.add(jMenu1);
// Finally
setJMenuBar(jMenuBar1);
and with this the Menu "About" is…

Johnydep
- 6,027
- 20
- 57
- 74
7
votes
5 answers
How to make a JMenu have Button behaviour in a JMenuBar
I was trying to make a JMenu behave like a JButton but I'm having some problems and hopefully someone here can help!
I've added a MenuListener to the JMenu item with this but I cant get the popup menu/focus to leave to enable me to properly click…

Kurru
- 14,180
- 18
- 64
- 84
6
votes
2 answers
JComboBox that is a Menu
I'm looking to create a JComboBox that acts as a menu. For example, when you drop it down, you can select items like you would in a JMenuBar.
So it would take JMenus and JMenuItems as instead of Strings.
Is this possible?

user489041
- 27,916
- 55
- 135
- 204
6
votes
2 answers
Programmatically expand sub JMenuItems
I would like to programmatically expand a particular JMenuItem in a JPopup. For example in the code below
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import…

Jamesy82
- 369
- 3
- 10
6
votes
3 answers
Java Swing - Add leniency when selecting items in submenus
When attempting to click on an item in a submenu, it is natural to quickly draw your mouse across the menu items below it. Both Windows and Mac natively handle this by putting a small delay before the a menu is opened. Swing JMenus do not handle…

flutillie
- 554
- 1
- 7
- 19
5
votes
0 answers
Why does JMenu not render correctly when using System L&F?
Bug Report
This has been confirmed as a bug. You can track it here:
https://bugs-stage.openjdk.java.net/browse/JDK-8258934
Background
There's no other code running besides what I've posted in the MCVE; there are no other JVMs active when running…

Vince
- 14,470
- 7
- 39
- 84
5
votes
0 answers
JMenuItem unwanted tint
I am creating a program that uses both a JMenuBar and a JPopupMenu with a windows LaF (look and feel).
Here is the simplified LaF code:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
…

Daedric
- 502
- 4
- 23
5
votes
2 answers
Dynamically add menuitem in menu without closing the menu
I want to add JMenuItem without closing JMenu. A menu contains a JTextField, When I press enter in text field, it added a menu Item. My problem is the size of added menu item is too small.
import java.awt.event.ActionEvent;
import…

vinu k n
- 861
- 1
- 6
- 14
5
votes
2 answers
How to set an accelerator for a JMenu sub menu?
I have a user request to add an accelerator to a sub menu (JMenu) which would allow the user to press the short cut and have the corresponding sub menu "fold out", showing its contained menu items.
I don't recall every having seen something like…

Urs Beeli
- 746
- 1
- 13
- 30
5
votes
1 answer
Extending JMenu to give it a check box?
I'm planning on combining JMenu and JCheckBoxMenuItem so I can have:
(1) a popup menu containing instances of this new component.
(2) this new component would have a check box on the left as well as being able to expand to the right and show other…

Robert
- 247
- 4
- 12