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
|
import java.awt.event.*;
import javax.swing.*;
public class test_1 implements ActionListener{
//attribut
JFrame frame;
JPanel p1;
JRadioButton radio_oui,radio_non;
ButtonGroup B;
JButton V;
//constructeur
test_1()
{
frame= new JFrame();
p1=new JPanel();
V=new JButton(" Annuler ");
V.addActionListener(this);
radio_oui=new JRadioButton("OUI");
radio_non=new JRadioButton("NON");
B=new ButtonGroup();
B.add(radio_oui);
B.add(radio_non);
radio_oui.setActionCommand("oui");
radio_non.setActionCommand("non");
p1.add(radio_oui);
p1.add(radio_non);
p1.add(V);
frame.getContentPane().add(p1);
frame.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
test_1 inst=new test_1();
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
if(arg0.getSource()==V)
{
//remise a zero des valeure de radios
}
}
} |