COMO PUEDO SABER QUE CHECKBOX TENGO SELECCIONADO
Publicado por Erwin Auner (6 intervenciones) el 12/03/2020 16:30:54
ya intente con .isSelected(); pero el comando no existe!
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package pkgIFG;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Choice;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class IFG extends JFrame {
public String esc;
public static void main(String argv[]) {
new IFG();
}
IFG(){
super("User Datails");
setLayout(null);
Choice choArticulos = new Choice();
Label IbITitulo = new Label("Articulos de Papeleria ");
CheckboxGroup escolaridad;
escolaridad = new CheckboxGroup();
Checkbox escolaridadPri, escolaridadSec, escolaridadPre, escolaridadPro;
JLabel Etiqueta= new JLabel("User Datails");
Etiqueta.setBounds(50,50,100,20);
add(Etiqueta);
JLabel Etiqueta2= new JLabel("Name");
Etiqueta2.setBounds(50,100,100,20);
add(Etiqueta2);
JLabel Etiqueta3= new JLabel("Address");
Etiqueta3.setBounds(50,150,100,20);
add(Etiqueta3);
JTextField c=new JTextField(" ");
c.setBounds(100,100,150,25);
add(c);
JTextField c2 = new JTextField(" ");
c2.setBounds(100,150,150,25);
add(c2);
JCheckBox cb = new JCheckBox(" C# ");
cb.setBounds(300,200,100,50);
add(cb);
JCheckBox cb2 = new JCheckBox(" Asp ");
cb2.setBounds(300,150,100,50);
add(cb2);
escolaridadPri = new Checkbox("Male ", escolaridad, false);
escolaridadPri.setBounds(300,50,100,50);
add(escolaridadPri);
escolaridadSec = new Checkbox("Female ", escolaridad, false);
escolaridadSec.setBounds(300,100,100,50);
add(escolaridadSec);
Checkbox sel =escolaridad.getSelectedCheckbox();
String a = sel.getLabel();
if(escolaridadPri.isSelected()){
esc="Male";
} else {
esc="Female";
}
choArticulos.addItem("Mumbal");
choArticulos.setBounds(100,250,150,25);
choArticulos.addItem("Bangalore");
choArticulos.addItem("Hydrebab");
add(choArticulos);
add(IbITitulo);
JButton boton =new JButton("Submit");
boton.setBounds(300,250,100,25);
add(boton);
setSize(500,400);
setVisible(true);
boton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "Nombre: "+c.getText()+"\nDireccion: "+ c2.getText()+"\nSexo: "+a);
}
});
}
}
Valora esta pregunta


0