JMenuBar Question
Hello there, i'm very new to this so if this is a silly question then don't treat me too harshly. I am trying to design a GUI and i'm having problems implementing the Menu (adding Load and Quit functions to the GUI), I think I have all the code that I need but the items just aren't displaying.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclass GUI
implements ActionListener
{
private JFrame frame;
public GUI()
{
makeFrame();
}
privatevoid makeFrame()
{
frame =new JFrame("GUI");
Container contentPane = frame.getContentPane();
frame.setSize(250,250);
frame.setLocation(100,100);
frame.pack();
frame.setVisible(true);
}
publicvoid actionPerformed(ActionEvent event)
{
System.out.println("Item: " + event.getActionCommand());
}
privatevoid makeMenuBar(JFrame frame)
{
JMenuBar menubar =new JMenuBar();
frame.setJMenuBar(menubar);
JMenu fileMenu =new JMenu("File");
menubar.add(fileMenu);
JMenuItem openItem =new JMenuItem("Open");
openItem.addActionListener(this);
fileMenu.add(openItem);
JMenuItem quitItem =new JMenuItem("Quit");
quitItem.addActionListener(this);
fileMenu.add(quitItem);
}
}
Any tips or corrections would be much appreciated, especially if someone could also explain how the JFileChooser could be added to the Load function.
Thanks,
cjr87.

