import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; class IconFrame extends JFrame { public IconFrame() { addWindowListener(new TerminationListener()) ; setTitle("IconFrame") ; setSize(450, 300) ; JMenuBar menuBar = new JMenuBar() ; setJMenuBar(menuBar) ; JMenu relaxMenu = new JMenu("Relax") ; menuBar.add(relaxMenu) ; javaItem = new JMenuItem("Refreshments", new ImageIcon("java.gif")) ; relaxMenu.add(javaItem) ; musicItem = new JMenuItem("Music", new ImageIcon("speaker.gif")) ; relaxMenu.add(musicItem) ; } private JMenuItem javaItem, musicItem ; } public class IconTest { public static void main(String [] args) { JFrame frame = new IconFrame() ; frame.show() ; } } class TerminationListener implements WindowListener { public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { System.exit(0) ; } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} }