Java swing implementation of a menu bar. JMenu objects are added to the menu bar to construct a menu.
Questions tagged [jmenubar]
263 questions
16
votes
5 answers
add JMenuBar to a JPanel?
I've got a JMenuBar and a JPanel. I'd like to add the JMenuBar to the JPanel. How would I do so?

Skizit
- 43,506
- 91
- 209
- 269
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
10
votes
1 answer
How can I add a JTextField to a JFrame's MenuBar?
I've been trying to overload JMenu and put in some custom code to support a JTextField but that isn't going well. My main purpose here is to add a search field to the right of my menu items. So I have something like File, Edit, help on the left…

Grammin
- 11,808
- 22
- 80
- 138
9
votes
7 answers
Adding spacing between elements in JMenuBar
Elements such as File, Edit etc. are too close together when using the JMenuBar in my application, it would look much nicer if there were some space between the elements. Is this possible?

Andrei0427
- 573
- 3
- 6
- 18
7
votes
4 answers
How do I move my JMenuBar to the screen menu bar on Mac OS X?
When I move my JMenuBar to the screen menu bar on Mac OS X, it leaves some blank space where the menu would be in my window; I need to remove that space. I am using
System.setProperty("apple.laf.useScreenMenuBar", "true")
to move my JMenuBar to…

tnecniv
- 587
- 2
- 5
- 12
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
2 answers
How to add JMenuBar shortcuts?
Adding shortcuts to JMenuBar submenu items in the Java Swing GUI designer is obvious, but how are shortcuts added to JMenuBar main menu items?

jacknad
- 13,483
- 40
- 124
- 194
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
7
votes
2 answers
Changing a JMenuBar border
I'm trying to change the border of a JMenuBar with an other border. Like that (for example) :
From Image 1 http://img11.hostingpics.net/pics/696780Sanstitre.png
To Image 2 http://img11.hostingpics.net/pics/900299Sanstitre2.png…

user1534422
- 511
- 1
- 8
- 14
7
votes
2 answers
Activate JMenuBar on hover
The JMenuBar does not start showing JMenuItems as selected or displaying the JMenu popups until it is first clicked upon. After you click somewhere in the JMenuBar, all these items respond to mouse hovers.
I would like to bypass the initial click…

springcorn
- 611
- 2
- 15
- 28
7
votes
2 answers
Java JMenuItem ActionListener
I need some help with my ActionListener on my JMenuBar.
There's no error; however every time I click on a JMenuItem, it triggers all the action associated with the JMenuItem. My question is: am I doing it right in my ActionListener code? I'm not too…

Zyrax
- 171
- 2
- 7
- 16
6
votes
4 answers
In NetBeans how do I add a jMenuBar to a JPanel?
I am having problems and I don't really understand why. I have a JFrame and a JPanel and everything works properly. I am trying to add a jMenuBar into the JPanel and I cannot get it to show up. It is being placed under "Other Components" and…

AdamOutler
- 870
- 4
- 13
- 29
6
votes
8 answers
Adding a clickable, action-firing JMenuItem directly to a JMenuBar?
Is there a way to add a JMenuItem (or similar button-type object) to a JMenuBar?
Adding a JMenuItem doesn't play well with the layout of a JMenuBar, and buttons look too button-like.
Should we be tweaking the button to look like a JMenuItem or…

thedude19
- 2,643
- 5
- 34
- 43
6
votes
3 answers
Java - Is it possible to add a JMenuBar to a JFrame's decoration window?
I'm wondering if I can add a JMenuBar to a JFrame or JRootPane's Decoration window, or otherwise the border that surrounds the content pane within. I see applications like Firefox or Photoshop having their menubar in the decoration window.
Is this…

Frizinator
- 1,351
- 3
- 12
- 16
5
votes
4 answers
The JPanel contentpane confusion
I am learning Java Swing and I appended a menuBar to the frame. By default this should call jframe.getContentPane().add(child). When I ran the script the menuBar didn't show up. But the button was at the very top "y=0" if that makes sense.
Then I…

Lews Therin
- 10,907
- 4
- 48
- 72