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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
package com.app.job;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
public class FenMenu extends JMenuBar {
private JMenuBar menuBar = new JMenuBar();
private JMenu test1 = new JMenu("Fichier");
private JMenu test1_2 = new JMenu("sous fichiers");
private JMenu test2 = new JMenu("Edition");
private JMenuItem item1 = new JMenuItem("Ouvrir");
private JMenuItem item2 = new JMenuItem("Fermer");
private JMenuItem item3 = new JMenuItem("Lancer");
private JMenuItem item4 = new JMenuItem("Arreter");
private JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem("choix 1");
private JCheckBoxMenuItem jcmi2 = new JCheckBoxMenuItem("choix 2");
private JRadioButtonMenuItem jrmi1 = new JRadioButtonMenuItem("Radio 1");
private JRadioButtonMenuItem jrmi2 = new JRadioButtonMenuItem("Radio 2");
public FenMenu () {
this.test1.add(item1);
this.test1_2.add(jcmi1);
this.test1_2.add(jcmi2);
this.test1_2.addSeparator();
ButtonGroup bg = new ButtonGroup();
bg.add(jrmi1);
bg.add(jrmi2);
jrmi1.setSelected(true);
this.test1_2.add(jrmi1);
this.test1_2.add(jrmi2);
this.test1.add(this.test1_2);
this.test1.addSeparator();
item2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
this.test1.add(item2);
this.test2.add(item3);
this.test2.add(item4);
this.menuBar.add(test1);
this.menuBar.add(test2);
}
} |