0% found this document useful (0 votes)
26 views1 page

Jmenu

The document is a Java program that creates a simple graphical user interface (GUI) with a menu bar. It includes a 'File' menu with options to create a new file, open an existing file, and save a file, along with 'Edit' and 'Help' menus. The program sets up a JFrame and makes it visible to the user.

Uploaded by

louisserivera27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Jmenu

The document is a Java program that creates a simple graphical user interface (GUI) with a menu bar. It includes a 'File' menu with options to create a new file, open an existing file, and save a file, along with 'Edit' and 'Help' menus. The program sets up a JFrame and makes it visible to the user.

Uploaded by

louisserivera27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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);
}
}

You might also like