Questions tagged [jmenu]

361 questions
3
votes
5 answers

a GUI java program needing an action event button

I am making a simple java program that represents a Microsoft Word menu bar, and in the file menu I add an exit button... it does nothing. I need your help to tell me what to do to make the exit button actually exit and close the program. Here is my…
user898342
  • 31
  • 2
3
votes
3 answers

Java repainting a component at mouse-over.

I am attempting to make my first properly customised GUI, but I am having difficulty changing the image which has been painted for a component. Basically, for my exitButton (a JMenu) I overwrite the paint method, and then add a Mouse listener, but I…
Ben Calder
  • 61
  • 2
  • 4
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
2 answers

what is the difference between JMenuItem and JMenu

What is the difference between JMenuItem and JMenu? JMenu m; JMenuItem i;
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
3
votes
2 answers

How to make window close on clicking "exit" MenuItem()?

public class Manubar extends JFrame { JMenuBar jmb; JMenu jm; JMenu jm2; JMenuItem jmt; JMenuItem jmt2; public Manubar() { setSize(500, 500); jmb = new JMenuBar(); jm = new JMenu("file"); …
chris
  • 141
  • 2
  • 8
3
votes
1 answer

Keystroke/Hot Key for JButton in Java

Initially I was using JMenu and establishing hot keys to work using accelerator. It was working perfectly. Now I want the same behavior in JButton but I am stuck. Here is the code that I wrote : Please share your ideas so I can go in the right…
Gemcode
  • 121
  • 12
3
votes
3 answers

Adding a submenu

So I tried to look at the Java docs for help for this but got confused pretty quickly. I am trying to add a submenu to the menu item 'Edit' which will have submenus Copy and Paste, and I'm note sure how to do it. I have a submenu variable created,…
Daniel D
  • 369
  • 3
  • 5
  • 14
3
votes
0 answers

How to remove the border on a JMenu or JMenuItem

I'm using Eclipse Luna with Java 1.7 and am trying to create a JPanel that has a JMenuBar. This JMenuBar contains a JMenu which again contains a JMenuItem. To fit the whole JMenuBar into my project's visual design, I changed the background and…
Almato
  • 53
  • 8
3
votes
0 answers

How to open an image from JMenu in Java?

I'm trying to open an image when the user clicks a certain button in my JMenu. I have to configure the m5 and m6 from this code: import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import…
Sebastian
  • 155
  • 5
3
votes
3 answers

How to get the index of a JMenuItem in the JMenu?

I need to find the index of a specific JMenuItem in a JMenu so I can programatically insert() a new JMenuItem right before it. How can I go about doing that?
Aviv Cohn
  • 15,543
  • 25
  • 68
  • 131
3
votes
1 answer

How to change icon for JmenuItem on rollover

I want to put a rollover effect in my JMenu this is my code: Icon firstPicAcc= new ImageIcon(Welcome.class.getResource("/app/resources/user1.jpg")); Icon secPicAcc= new ImageIcon(Welcome.class.getResource("/app/resources/user2.jpg")); JMenu…
harraypotter
  • 111
  • 2
  • 2
  • 11
3
votes
1 answer

Disable JMenu when all of its items are disabled

I'm trying to make my JMenu disabled when all of its subitems are disabled. I have a menu "Add new" and in this menu two menu items: "File" and "Directory". The menu items are bound to particular actions whose states I change, so menu items change…
Shocked
  • 627
  • 4
  • 13
3
votes
3 answers

How to set a size for JMenuItem?

As you can see, it's ugly to have these kind of JMenuItems. The width of the menu items is quite small. Here is the code: JMenu menuOne=new JMenu("MenuOne"); JMenu menuTwo=new JMenu("MenuTwo"); JMenu menuThree=new JMenu("MenuThree"); …
Zalberth
  • 308
  • 1
  • 2
  • 12
3
votes
2 answers

Adding a JScrollPane to a JMenu

I have a JMenu which will include JMenuItems that are generated on start-up from a database. As such, it's quite likely that the menu will be too large and run off the screen. As such, I am trying to add a JScrollPane to the JMenu. Example, to the…
Rudi Kershaw
  • 12,332
  • 7
  • 52
  • 77
1 2
3
24 25