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.

342 questions
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…
4
votes
1 answer

How to prevent JMenuItem from closing Menu upon clicking the JMenuItem

How do I prevent a JMenuItem from closing the menu when the JMenuItem is clicked? The JMenuItem is enabled. So this is the scenario, I have 3 JMenuItems: JMenuItem: A, B, C; C displays an integer X. A and B are used to increment or decrement X by a…
Philip Nguyen
  • 871
  • 2
  • 10
  • 29
4
votes
2 answers

Creating menus for JApplet

I am making a simple game where numbers fall from top to bottom and I have to type the number. (number is erased as I type the number) This is coordinated with a Zen.java which is a JApplet file. I am trying to make a menu for this game with a…
金允雄Oliver
  • 229
  • 2
  • 13
4
votes
1 answer

How to catch click on a JMenu element?

I'm developping a Java/Swing application with a menu using JMenuBar, JMenu and JMenuItem. System look and fell is applied to the UI. UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); I have several top level elements for my…
Sly
  • 2,105
  • 5
  • 22
  • 28
4
votes
2 answers

Why my ChangeListener reacts only for JMenu, and not for JMenuItem?

Now, I have a JMenu, and some JMenuItems in it. I want my program to perform some action when JMenu's and JMenuItem's state is changed to "selected". I don't use MouseLitener's MouseOver, because I want user to be able to navigate in menu using…
nicks
  • 2,161
  • 8
  • 49
  • 101
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

Adding custom elements to a JPopupMenu

The problem can be stated in two different ways: 1. I have a JPopupMenu where I want to insert a component which is not a JMenuItem (a custom JTree)... but I dont know how to do it or 2. I have a different Popup (JPopupPanel) and I want to add…
spuas
  • 1,683
  • 1
  • 16
  • 26
4
votes
3 answers

Double icons with JMenuItem setHorizontalTextPosition on Win

Two icons are rendered when using JMenuItem setHorizontalTextPosition(SwingConstants.LEFT) with Windows Look and Feel. It works fine with the default Java Look and Feel. I just filed a Java bug report, posting here for anyone else having the same…
kjohnson
  • 110
  • 1
  • 4
4
votes
2 answers

JFrame Action Listener that listens to all menu items?

So I have a JFrame set up with a menu with the current structure that looks something along the lines of this: File Exit Pages Reviews A B C Help About I want to create a Action Listener that only listens to menu items under…
Spedwards
  • 4,167
  • 16
  • 49
  • 106
4
votes
2 answers

Command Pattern Usefulness when using JComponents

So, I'm developing a program using the Swing library and I obviously have buttons and menu items. Some of these are supposed to do the same stuff, and I thought using the Command Pattern should be the way to do it, e.g. I have a "save" button and a…
4
votes
1 answer

Hotkey for JMenuItem of JPopupMenu

I have added a JPopupMenu with certain JMenuItems to a JTable in my java application. I then set accelerators for those JMenuitems. Now my problem is that when I try to use those hotkeys, they don't work until I open that JPopupMenu. When that popup…
user2067787
  • 130
  • 8
4
votes
2 answers

Disable menu items programmatically

I am working on a Desktop app with the Netbeans RCP. I have a number of menu items that are beeing added to the menu through annotations in the TopComponents. I would like to be able to disable several of these menu items, depending on the access…
4
votes
2 answers

Align icon and JCheckbox in JPopupmenu

I have a Problem with some icons and check-boxes in a JPopupMenu. The Check-boxes and Icons are not aligned The Items are created like: JMenuItem deleteAttributeMenuItem = new JMenuItem(locale.getString("TREE_AttrDelete"), iconDelete); JMenuItem…
Andreas Freitag
  • 357
  • 1
  • 7
  • 20
3
votes
1 answer

Inserting a vertical separator between Icon and Text in JMenuItem

I'm trying to insert / display a vertical separator between the icon and the text of the JMenuItem components in my applications. I create a JMenuItem as follows (roughly): JMenuItem cutMenuItem = new…
eternaln00b
  • 1,043
  • 9
  • 18
1
2
3
22 23