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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| public class Fenprincipale extends JMenuBar {
public Fenprincipale() {
super();
initializeMenu();
}
private void initializeMenu() {
JMenu menu_file = new JMenu("File");
JMenuItem open = new JMenuItem("Open");
JMenuItem close = new JMenuItem("Close");
JMenuItem exit = new JMenuItem("Exit");
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
menu_file.add(open);
menu_file.add(close);
menu_file.add(exit);
add(menu_file);
JMenu menu_edit = new JMenu("Mise à jour");
JMenuItem ajout = new JMenuItem("Ajout");
JMenuItem modif = new JMenuItem("modification");
JMenuItem eval = new JMenuItem("Evaluation");
ajout.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Ajout")){
new Insert().setVisible(true);
}
}}); menu_edit.add(ajout);
menu_edit.add(modif);
menu_edit.add(eval);
add(menu_edit);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
JLabel label = new JLabel("KATRAS");
//Container contenu = getContentPane() ;
// contenu.setLayout(new FlowLayout()) ;
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(250, 200));
frame.setJMenuBar(new Fenprincipale());
frame.pack();
frame.setVisible(true);
} |
Partager