Java swing implementation of a menu bar. JMenu objects are added to the menu bar to construct a menu.
Questions tagged [jmenubar]
263 questions
5
votes
1 answer
Swing application menu name not displaying correctly in Java 1.8
Okay, so I've done Swing applications before, and I know if you want to display a different name for the application menu (the one on Macs that usually have a "Preferences" and "Quit" option), you have to use:…

mistShaker
- 53
- 1
- 5
5
votes
3 answers
how to call a method from another class Java Swing?
I have the following SwingMenu class.
package base;
import javax.swing.*;
public class SwingMenu {
public static void main(String[] args) {
SwingMenu s = new SwingMenu();
}
public SwingMenu() {
JFrame frame = new…

JoJo
- 4,643
- 9
- 42
- 65
5
votes
2 answers
JMenuBar not showing
I seem to have done everything correct. I just need to implement a simple JMenuBar but it seems to be not working. Can someone please help me out in this?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import…

user1450466
- 51
- 1
- 1
- 2
4
votes
1 answer
java remove JMenuBar
I have a frame containing a JMenuBar. If the users clicks the "Logout" MenuItem, I would remove all the frame's content and initialize it with other content. The issue is that if I call
parent.getContentPane().removeAll();
LoginActivity l = new…

Teo
- 3,394
- 11
- 43
- 73
4
votes
0 answers
Action event not firing for JMenuItem accelerator keystroke?
I have a simple java swing application. It's mostly used on Macos, so I'm trying to add a default menu bar to it through Desktop.getDesktop().setDefaultMenuBar(...). I defined a menu bar with a "File" menu and a "New" menu item with an action…

Kenster
- 23,465
- 21
- 80
- 106
4
votes
1 answer
JMenu not appearing until window is resized
I am trying to create a sample program that has a menu and some options on it.
The problem is When i run the program, the menu does not appear until the window is re-sized. I am not sure what the problem is and I would appreciate any help.
Here is…

yj2000
- 63
- 1
- 8
4
votes
3 answers
JMenuBar at the top in MacOSX
In the Java Desktop Application template used by Netbeans, a menu bar is created with JMenuBar and JMenuItems.
How can I get that bar displayed at the top, where menu bars are displayed in MacOSX instead of in-window, like in Windows?

Pablo Fernandez
- 279,434
- 135
- 377
- 622
4
votes
2 answers
Example Program JMenubar on JInternalFrame when i Maximize the JInternalFrame
Hi I need an Example program in which
When i maximize the JInternalFrame the JMenuBar of JFrame should set on JInternalFrame
and When i minimize the JInternalFrame again the JMenuBar should leave JinternalFrame and set
to JFrame as shown…

Zaheer
- 123
- 5
- 14
4
votes
3 answers
Create multiple menubars with icons in Swing
I am working on a Swing application in which I have to create multiple menubars on clicking a menu.
The other menubar either should be added or removed from the container.
I have to use an icon above and below text in the menu, but I have not…

adesh kumar
- 129
- 3
- 10
4
votes
2 answers
JMenu doesn't appear until I minimize or resize the JFrame
I have a GUI with a JMenuBar, the problem is that sometimes a JMenu doesn't appear until i resize or minimize the JFrame. Can someone help me?

Stephen Franco
- 41
- 2
4
votes
2 answers
Nimbus Look And Feel adjust colors of menubar
I am trying to adjust the colors of the Nimbus Look and Feel but it is only working partially. Especially I have problems adjusting the colors of the menubar.
Here is a running example:
import java.awt.Color;
import java.awt.Dimension;
import…

hami
- 443
- 5
- 13
4
votes
2 answers
set JMenuBar's background color?
relatively straight-forward, how can I set the background color of a JMenuBar?
ive tried:
MenuBar m = new MenuBar() {
void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setBackground(Color.yellow);
g2.fillRect(0, 0,…

Primm
- 1,347
- 4
- 19
- 32
3
votes
1 answer
Swing menu item on right of Menu Bar
I have a swing application and on the JFrame's menu I want to add a Help MenuItem, but have it Right justified.
Any ideas ?
A Swing JMenuBar has a BoxLayout and I have tried:
menuItem = new…

Romain Hippeau
- 24,113
- 5
- 60
- 79
3
votes
2 answers
How to take out white borders in JMenu and JMenuItems
I'm doing this Graphic Interface with Swing. The problem that i'm having is that i can't take the white borders that are arround the JMenuItems, and paint it all of black. Here is an image:
I would like to paint it like this (I have edited the…

Joaco Terniro
- 115
- 1
- 2
- 13
3
votes
1 answer
Swing: How to provide delay on opening menu from menu-bar/submenu
I have an application with a vertical menu bar and lots of submenus. My problem is: submenu goes open immediately after entering by mouse over the corresponded label in parent menu/menu bar. But I need one second delay.
Here is one example:
When I…

Sergiy Medvynskyy
- 11,160
- 1
- 32
- 48