JMenuBar « Menu « Java Swing Q&A





1. Why won't my JMenuBar show up?    stackoverflow.com

I'm trying to make a GUI in java, but JMenuBar has been giving me a hard time for two days. Can someone please tell me why it isn't showing up?

import java.awt.*;
import ...

2. Controlling JFrame from JMenuBar    stackoverflow.com

I am trying to maximize JFrame from within JMenuBar, I can not pass a reference to the frame. Is it possible to get a reference to the frame that it is ...

3. Java JMenuItem Accelator Snow Leopard    stackoverflow.com

about = new JMenuItem("About");
about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A((Toolkit.getDefaultToolkit().getMenuShortcutMask()))));
JMenu help = new JMenu("Help");
help.add(about);
I was wondering why my aaccelerators were not working. I am running this in snow leopard with JavaSe-1.6 VM. They do work if I ...

4. Fickle JMenuBar    stackoverflow.com

I ran the following code 10 times. Of the 10 runs, 3 showed both the menu bar and the rectangle, 3 showed only the rectangle, and 4 showed nothing at all. ...

5. How to make a JMenu have Button behaviour in a JMenuBar    stackoverflow.com

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 ...

6. JPanel Appears Behind JMenuBar    stackoverflow.com

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

@SuppressWarnings("serial")
public class Main extends JFrame {

    final int FRAME_HEIGHT = 400;
    final int FRAME_WIDTH = 400;

    public static ...

7. Java - Is It Possible To Add A JMenu Over On The Far Right-Hand Side Of A JMenuBar?    stackoverflow.com

I am in the process of developing a simple JFrame based GUI to which I've added a JMenuBar and which in turn has the usual JMenuItems added to it - "File:", ...

8. Swing JMenuItems getting shown behind Applet    stackoverflow.com

I am working on a Swing application in which I am trying to display an Applet (processing PApplet) inside of a JFrame. The frame has a JMenuBar attached to it. When ...

9. add JMenuBar to a Jpanel?    stackoverflow.com

I've got a JMenuBar and a JPanel. I'd like to add the JMenuBar to the JPanel. How would I do so?





10. Cascading JMenus inside JMenuBars    stackoverflow.com

I have JTable and have assigned it a custom TabeCellEditor and TableCellRenderer customRenderer and customEditor. Each entry in the table represents a message. The custom editor is a JPanel which displays message ...

11. How to add a JPopupMenu to a JMenuBar?    stackoverflow.com

I have an application with a popup menu. I'd like to use the popup in the usual way (i.e., it should appear when the user right-clicks anywhere in the window), ...

12. JMenubar error?    stackoverflow.com

import javax.swing.*;

class Main {

public static void main(String[] args) {
    JFrame frame = new JFrame();

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = ...

13. Why does the compiler not run the program even though there are not any errors?    stackoverflow.com

I have a program that is not showing any errors in Eclipse, but whenever I click the run button, nothing happens. I get the code lines in the compiler console that ...

14. Why does my program compile but it not run?    stackoverflow.com

This is a follow up question due to changes being made to the OP code. Another user suggested I link the other question to this one. The OP is :

15. How to draw a JMenuBar on top of a graphics    stackoverflow.com

I am writing a basic timer program with Java, and in the program I would like to have a menu bar at the top. The code I have as of now ...

16. Java swing JMenuBar sometimes doesn't show up    stackoverflow.com

I am working on a Java desktop application, and sometimes my jmenubar shows up, sometimes it doesn't. When it doesn't the entire program freezes and I have to kill it. I ...





17. The JPanel contentpane confusion    stackoverflow.com

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 ...

18. can't set JMenuBar    stackoverflow.com

I have a GUI I am trying to add a menubar to but every time I try to add the JmenuBar it says it's expecting a java.awt.menubar and found a java.swing.Jmenubar ...

19. Java Swing JMenuBar    stackoverflow.com

my JMenuBar is not showing AT ALL. This is just a barebones GUI. I have sat here for quite a while now, and I cannot see the problem, soo, as they ...

20. JMenuBar with Synth    stackoverflow.com

Would someone please help me to create a simple frame with a JMenuBar using Synth L&F as I read multiple tutorials and I can't seem to get it right. Don't know ...

21. GUI Builder: Cannot remove JMenuBar from JPanel    forums.netbeans.org

I didn't know that you can't add a menu bar to a JPanel, so I dragged 2 of them in. They didn't appear on the Design view, so I realised that it wasn't possible. However, they are there (as private variables, and initialised in the initComponents method), along with all their associated menu items in the generated Source view. I have ...

22. JMenuBar and JMenu    coderanch.com

23. Dynamically changing a JMenuBar    coderanch.com

24. JMenuBar    coderanch.com

25. JMenuBar error.    coderanch.com

26. adding help to the JMenuBar    coderanch.com

you cant do that in swing. at least not in the way u want to, using thhat method. here is what i took from the API: Sets the help menu that appears when the user selects the "help" option in the menu bar. This method is not yet implemented and will throw an exception. as u see, this method is not ...

27. adding helpmenu to a JMenuBar.    coderanch.com

29. JMenuBar listner???    coderanch.com

30. JMenuBar Rollover    coderanch.com

Hi Gregg, This is a very interesting question, you have. I'm shure, many users will like it. I made a little test and at least I could popup the menu when the mouse was over and I could close the menu when the mouse exited. But this was easy. There is something more to do. You have to take care, that ...

31. JMenuBar reference being set to null!    coderanch.com

Originally posted by Michael Morris: Hi Steven, That is odd. Is it possible that the bean container is doing something with the reference? Have you tried just compiling and running from a command line? If you can remove any IDE dependencies and test it that way, it may give you some more insight as to what's happening. Hope this helps, Michael ...

32. simple JMenuBar, JMenu question ..    coderanch.com

33. JMenuBar Question    coderanch.com

34. Vote for Java Bug: JMenuBar.setHelpMenu()    coderanch.com

hello all, the method JMenuBar.setHelpMenu() throws an UnsupportedOperationException as it is "not yet implemented". This is the case since version 1.2. this bug (request for enhancement): http://developer.java.sun.com/developer/bugParade/bugs/4087846.html is in the database since 1997! It never should have been necessary to put it there, in my opinion. If they ever planned to implement the method, they should have done that at last ...

36. Thread-safe JMenuBar and JFrame ?    coderanch.com

Hi all. I'm trying to create a menu bar and a few menu items, but using an applet invoked by an html script. The menu items in the applet will have actionlisteners for buttons etc On clicking a menu item , another screen (GUI) will pop up, contained in its own frame. It will be refreshed continuosly from there on i.e. ...

37. JMenuBar in an Applet : Good vs Bad Code Practice?    coderanch.com

Hi, after a day of experimenting, following code is the only way I can get a JMenuBar in an applet, which gets invoked by html. I can further refine it by putting the menu bar in a JTextArea in borderlayout north, but the question is whether there is a better way, and whether this code is the normal way to put ...

38. JScrollPane and JMenuBar are incompatible?    coderanch.com

Jose, yes, I've got a bunch of stuff in the scrollpane that shows up just fine. There's so much that it takes up the entire frame minus the menubar and requires a scrollpane to fit all of it. Hence my choice of using a scrollpane. Don, yeah it worked fine before I put in the scroll pane. I've got a suspision ...

39. Updating JMenuBar    coderanch.com

import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; public class MenuFrame { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("test"); JMenuBar bar = new JMenuBar(); bar.add(new JMenu("Test")); frame.setJMenuBar(bar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JLabel("Test text")); frame.pack(); frame.setVisible(true); for (int counter = 0; counter < 10; counter++) { System.out.println(counter); JMenuBar bar2 = new JMenuBar(); bar2.add(new JMenu("Test" + counter)); frame.setJMenuBar(bar2); frame.repaint(); ...

40. adding JPopupMenu to a JMenuBar    coderanch.com

41. BufferStrategy and JMenuBar    coderanch.com

Hello there! I'm using a BufferStrategy to draw some graphics in my app, however, when the graphics appear, it will be drawn on top of my menubar. I searched around the forum for similar problems, but every solution suggested not to overload paint() or at least call super.paint(). As I have NOT overloaded paint(), the problem must be something else. Please ...

42. JMenuBar    coderanch.com

44. JMenuBar question    coderanch.com

45. How to add a HTML link to the JMenuBar?    coderanch.com

46. JMenubar/Jmenu/JMenuItem does not work    coderanch.com

Dear friends, I am facing a problame in using jmenu in my swing application. I am using netbeans5.5 for developing the form now in this form i attach a menubar and in menu bar 3 menues file, new form and exit. now when some one click on the exit menu the application should be exited. if new form menu clicked then ...

47. JMenuBar Layout    coderanch.com

48. I can't side set JMenuBar (top-down)    coderanch.com

50. JMenuBar problem in MAC    coderanch.com

Also note that I have added System.setProperty("apple.laf.useScreenMenuBar", "true") in the coding, so that all the menu items will be in the Mac menu bar. Once I make this false it appear as a normal JFrame window with the menu bar and it does not produce this issue. The reason for this behavior is moving the menubar from the frame to mac ...

51. about JFrame , JPanel and JMenuBar    coderanch.com

52. JMenuBars on Mac OS    coderanch.com

Hello everyone. I'm new to programming on Macs and I always did something like so on Windows/Linux to obtain a menu bar: public class TextFrame extends JFrame { public TextFrame() { this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setJMenuBar(new JMenuBar()); } } Evidently it works on Macs too but not quite how I want it. The Menu bar appears inside the window as oppose to on the ...

53. JMenuBar not using default alignment?    coderanch.com

private void createMenuBars(){ JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem newMenuItem = new JMenuItem("New"); JMenuItem loadMenuItem = new JMenuItem("Load"); JMenuItem saveMenuItem = new JMenuItem("Save"); JMenuItem exitMenuItem = new JMenuItem("Exit"); newMenuItem.addActionListener(new NewPuzzleListener()); saveMenuItem.addActionListener(new SavePuzzleListener()); loadMenuItem.addActionListener(new LoadPuzzleListener()); exitMenuItem.addActionListener(new ExitListener()); menuBar.add(fileMenu); // following added to test positioning possibilities menuBar.add(Box.createHorizontalGlue()); JMenu dummyMenu = new JMenu("Dummy"); menuBar.add(dummyMenu); // we are adding this ...

54. Resize problem with JMenuBar    coderanch.com

import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; public class Test { public static void main(String args[]) { JFrame frame = new JFrame("Test Frame"); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu Test1 = new JMenu(); menuBar.add(Test1); Test1.setText("Test1"); JMenu Test2 = new JMenu(); menuBar.add(Test2); Test2.setText("Test2"); JMenu Test3 = new JMenu(); menuBar.add(Test3); Test3.setText("Test3"); JMenu Test4 = new JMenu(); menuBar.add(Test4); Test4.setText("Test4"); JMenu Test5 = new JMenu(); ...

55. JMenuBar covers content pane    coderanch.com

57. Create JMenuBar using DataBase    java-forums.org

I would separate the creation of the menu bar from the database part. start with getting a kind of "menu definition" data structure working to feed the creation of the jmenubar for example a "MenuBean" String label String shortcutKey List titems and a "MenuItemBean" String type; // will be used to determine what Swing menu item will be created (JMenuItem, JmenuSepartor, ...

58. Mutliple JMenuBar    java-forums.org

import java.awt.GridLayout; import javax.swing.*; public class NestedMenuBar { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new NestedMenuBar().makeUI(); } }); } public void makeUI() { JMenuBar outerBar = new JMenuBar(); outerBar.setLayout(new GridLayout(0, 1)); for (int i = 0; i < 2; i++) { JMenu menu = new JMenu("Menu " + i); menu.add(new JMenuItem("Item " + ...

59. JMenuBar and Popups    java-forums.org

Hi all, Hope you can help with this as I'm out of idea's on how to achieve it. I have a small app with a JMenuBar, a number of JMenu's which contain a number of JMenuItems, all very straightforward so far. The default behaviour of any JMenu is to appear within a popup below the JMenuBar item that has been selected ...

60. Adding jmenubar inside jtabbed pane    java-forums.org

Hello to all, I am doing some project and struck with a problem in swing.The problem is how to add a jmenubar inside jtabbed pane.I tried in netbeans,jmenu bar is adding to jframe but i require it to place inside jtabbedpane(without using jinternal frame).Please send me the email (suresh_m5a5@yahoo.co.in)if you know the solution. Thank you in advance. Regards, M.Suresh kumar, Scientist/Engineer ...

62. Find a tutorial on changing the JMenuBar    java-forums.org

I have made a GUI and the JMenubar and that works great. I am looking for a tutorial to teach me how to cancel out something. The simplest example I can think of if you go to edit and paste is grayed out. But you cut something and it works great. That is want to learn. I have tried creating two ...

63. 2 questions? GUI window's and JMenuBar    forums.oracle.com

hi 2 quick-ish questions. 1) Is it possible to open a GUI window from within another GUI window? e.g on click of a button open a new GUI with a 5x3 grid? and if possible, would this still be able to have item event handlers that affect the Main() window? 2) Can anyone show me some basic code to get a ...

64. JMenuBar under JTabbedPane    forums.oracle.com

65. JMenuItems in JMenuBar    forums.oracle.com

66. Adding JMenuBar to JFrame    forums.oracle.com

It's a simulation I'm doing for a physics class. Each object moves before I check collisions. The objects are not in any order in the array. Is there a better way to check only the objects close to each other? The program ran fine using my other implementation of BufferStrategy above. It only slowed down when the number of objects reached ...

67. align a JMenuBar to right in a JFrame    forums.oracle.com

68. Need help JMenuBar e JMenuItem    forums.oracle.com