JMenuBar mb = new JMenuBar();
JMenu file = new JMenu("File");
file.setMnemonic('F');
JMenuItem new_ = new JMenuItem("New");
new_.setMnemonic('N');
new_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new_();
}
});
file.add(new_);
file.addSeparator();
JMenuItem open = new JMenuItem("Open...");
open.setMnemonic('O');
open.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
open();
}
});
file.add(open);
JMenuItem save = new JMenuItem("Save");
save.setMnemonic('S');
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
save();
}
});
file.add(save);
JMenuItem saveAs = new JMenuItem("Save As..");
saveAs.setMnemonic('A');
saveAs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveAs();
}
});
file.add(saveAs);
file.addSeparator();
JMenuItem exit = new JMenuItem("Exit");
exit.setMnemonic('x');
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exit();
}
});
file.add(exit);