import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class FramewithAboutMenu extends JFrame {
public FramewithAboutMenu(String title) {
JMenuBar menuBar = new JMenuBar();
setTitle(title);
setJMenuBar(menuBar);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JMenu fileMenu = new JMenu("File");
JMenu elementMenu = new JMenu("Elements");
JMenu helpMenu = new JMenu("Help");
fileMenu.setMnemonic('F');
elementMenu.setMnemonic('E');
helpMenu.setMnemonic('H');
JMenuItem aboutItem = new JMenuItem("About");
helpMenu.add(aboutItem);
menuBar.add(helpMenu);
}
public static void main(String[] a) {
FramewithAboutMenu window = new FramewithAboutMenu("Sketcher");
window.setBounds(30, 30, 300, 300);
window.setVisible(true);
}
}
|