import javax.swing.
*;
public class Menu {
public static void main(String[] args) {
// Create the frame
JFrame frame = new JFrame("Menu demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
// Create the menu bar
JMenuBar menuBar = new JMenuBar();
// Create the "File" menu
JMenu fileMenu = new JMenu("File");
JMenuItem newItem = new JMenuItem("New");
JMenuItem openItem = new JMenuItem("Open");
JMenuItem saveItem = new JMenuItem("Save");
fileMenu.add(newItem);
fileMenu.add(openItem);
fileMenu.add(saveItem);
// Add menus to the menu bar
menuBar.add(fileMenu);
menuBar.add(new JMenu("Edit"));
menuBar.add(new JMenu("Help"));
// Set the menu bar for the frame
frame.setJMenuBar(menuBar);
// Make the frame visible
frame.setVisible(true);
}
}