import java.awt.*; import javax.swing.*; import java.awt.event.*; public class LiveMenuGUI extends JFrame implements ActionListener { JMenuItem mi; public static void main(String args[]) { LiveMenuGUI mg = new LiveMenuGUI(); } public LiveMenuGUI() { JPanel south = new JPanel(); JPanel centre = new JPanel(); JButton b1 = new JButton("Quit"); b1.addActionListener(this); south.add(b1); mi = new JMenuItem("Exit"); mi.addActionListener(this); JMenu m = new JMenu("File"); m.add(mi); JMenuBar mb = new JMenuBar(); mb.add(m); setJMenuBar(mb); Container c = getContentPane(); c.add(centre,BorderLayout.CENTER); c.add(south,BorderLayout.SOUTH); pack(); setSize(300,200); setVisible(true); } public void actionPerformed(ActionEvent ae) { String command = ae.getActionCommand(); if(command.equals("Quit")) { setVisible(false); dispose(); System.exit(0); } else if ( ae.getSource ( ) == mi ) { setVisible(false); dispose(); System.exit(0); } } }