Question

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 which is what it should detect. Here is my code.

class CipherGUIFrame extends JFrame{

   public CipherGUIFrame(){    
      super("Caesar Cipher GUI");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(400, 600);

      Container content = getContentPane();
      content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));    

      JMenuBar menuBar = new JMenuBar();

      menu = new JMenu("File");
      open = new JMenuItem("Open");
      save = new JMenuItem("Close");         

      menu.add(open);
      menu.add(save);
      menuBar.add(menu);

      setMenuBar(menuBar); // this line here is what gives me the error    
   }    
}
Was it helpful?

Solution

I think you need to use 'setJMenuBar' instead of setMenuBar

OTHER TIPS

You can try setJMenuBar() instead

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top