Fórum Como fazer funcionar um JRadioButton #568621
09/04/2009
0
if (RB1.isSelected()) { System.out.println("primeiro"); }
else if (RB2.isSelected()) { System.out.ptintln("segundo"); }
else { System.out.println("terceiro"); }
Pamela Gatinho
Curtir tópico
+ 0Posts
09/04/2009
Carlos Heuberger
Gostei + 0
09/04/2009
Bruno Carlo
JPanel panel = new JPanel();
ButtonGroup bg = new ButtonGroup();
b1 = new JRadioButton("ola 1");
bg.add(b1);
panel.add(b1);
b2 = new JRadioButton("ola 2");
bg.add(b2);
panel.add(b2);
b3 = new JRadioButton("ola 3");
bg.add(b3);
panel.add(b3);
//isso dentro de um actionListener, ou outro lugar qq
if(b1.isSelected()){
System.out.println("b1");
}else if(b2.isSelected()){
System.out.println("b2");
}else{
System.out.println("b3");
}
Gostei + 0
09/04/2009
Pamela Gatinho
if (RadioButton1.isSelected() ) {
Tela1 t1 = new Tela1();
t1.show();
}
else if (RadioButton2.isSelected() ) {
Tela2 t2 = new Telas2();
t2.show()
}
else {
Tela3 t3 = new Tela3();
t3.show();
}
Gostei + 0
09/04/2009
Bruno Carlo
Gostei + 0
09/04/2009
Carlos Heuberger
radioButton1.addActionListener(...
Gostei + 0
09/04/2009
Pamela Gatinho
Gostei + 0
09/04/2009
Carlos Heuberger
radioButton1.addActionListener(meuActionListener);
Gostei + 0