A.
import
java.awt.event.*;
import
javax.swing.*;
import
java.awt.*;
class
CobaMenu extends JFrame {
JMenuBar menuBar;
JMenu file, doc, edit, help;
JMenuItem open, save, exit, delete, copy, paste, about;
public CobaMenu() {
setTitle("Menu");
setSize(200,200);
file = new JMenu("File");
file.setMnemonic('F');
doc = new JMenu("Document");
doc.setMnemonic('D');
edit = new JMenu("Edit");
edit.setMnemonic('E');
help = new JMenu("Help");
help.setMnemonic('H');
open = new JMenuItem("Open");
open.setMnemonic('O');
save = new JMenuItem("Save");
save.setMnemonic('S');
exit = new JMenuItem("Exit");
exit.setMnemonic('X');
delete = new JMenuItem("Delete");
delete.setMnemonic('L');
copy = new JMenuItem("Copy");
copy.setMnemonic('C');
paste = new JMenuItem("Paste");
paste.setMnemonic('P');
about = new JMenuItem("About");
about.setMnemonic('A');
menuBar = new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(file);
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
menuBar.add(doc);
doc.add(edit);
edit.add(copy);
edit.add(paste);
edit.add(delete);
menuBar.add(help);
help.add(about);
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
}
public class MainMenu {
public static void main(String [] neno) {
CobaMenu m = new CobaMenu();
}
}
hasilnya adalah :
Tidak ada komentar:
Posting Komentar