-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyMenu.java
More file actions
31 lines (26 loc) · 867 Bytes
/
MyMenu.java
File metadata and controls
31 lines (26 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import javax.swing.*;
import java.awt.*;
public class MyMenu {
MyMenu(){
JFrame jframe = new JFrame("Menu Example");
jframe.setSize(400,400);
jframe.setLayout(new FlowLayout(FlowLayout.LEFT));
JMenuBar menuBar = new JMenuBar();
JMenu file = new JMenu("File");
menuBar.add(file);
JMenuItem save = new JMenuItem("Save");
file.add(save);
JMenu options = new JMenu("Options");
file.add(options);
JMenuItem tool = new JMenuItem("Tool");
options.add(tool);
JMenuItem close = new JMenuItem("Close");
file.add(close);
jframe.add(menuBar);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setVisible(true);
}
public static void main(String[] args){
new MyMenu();
}
}