Questions tagged [jmenuitem]

JMenuItem is an implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button", the action associated with the menu item is performed.

JMenuItem is an implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button", the action associated with the menu item is performed. For more info, see this link.

336 questions
20
votes
2 answers

How do you make menu item (JMenuItem) shortcut?

So i noticed that in awt there is a MenuItem constructor for adding a CTRL + (some key) shortcut, but there is no such constructor for JMenuItem. What is the correct way to do this? I need an equivelent of awt: MenuItem mi = new MenuItem("Copy", new…
Adrian Hristov
  • 1,668
  • 1
  • 14
  • 21
14
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,626
  • 7
  • 31
  • 53
12
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
  • 567
  • 6
  • 13
9
votes
1 answer

Why does a small JPopupMenu cause visual artifacts whereas a larger one doesn't?

I'm using a single row JTabel with a MouseAdapter attached to it. The table model is populated with some random values. Upon right-clicking the table a JPopupMenu with several JMenuItems will appear. Visual artifacts start showing if part of the…
Emiel
  • 195
  • 9
7
votes
2 answers

Adding a vertical separator in PopupMenu, in the task bar

How can I add a vertical separator in the pop up menu of the app in the task bar ? tray = SystemTray.getSystemTray(); openMenuItem = new MenuItem("Open P"); stopKLMenuItem = new MenuItem("Stop"); exitMenuItem = new…
Suhail Gupta
  • 19,563
  • 57
  • 170
  • 298
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
7 answers

How to prevent a disabled JMenuItem from hiding the menu when being clicked?

In my Java swing application i have noticed that when i click on a disabled JMenuItem in a JPopupMenu it hides the menu, but i i do not want to hide it, as if nothing is clicked. Is there a way to prevent this ? ----------------------------------->…
Brad
  • 4,279
  • 9
  • 52
  • 91
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
  • 395
  • 1
  • 5
  • 19
6
votes
1 answer

How I can change JMenuItem alignment to right align

I have written a program in java with netBeans editor. my form have a jmenuBar with some jmenu in right alignment. for example jmenu1 have some jmenuItem, i want right align all jmenuitem's text. when i change Horizontal alignment of them to right,…
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
  • 512
  • 3
  • 22
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
  • 731
  • 1
  • 5
  • 14
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
  • 237
  • 3
  • 12
5
votes
2 answers

How do I create this special menu bar with Java Swing?

I am trying to implement this type of menu using Swing. Is there any off-the-shelf solution (free and/or commercial) yet?
John Vu
  • 163
  • 1
  • 3
  • 7
4
votes
2 answers

How to enable copy/cut/paste jMenuItem

I am making text editor in netbeans and have added jMenuItems called Copy,Cut & Paste in the Edit menu. How do I enable these buttons to perform these functions after actionPerformed() Here is my attempt: private void…
1
2 3
22 23