JRadioButton r1=new JRadioButton("A) Male"); JRadioButton r2=new JRadioButton("B) Female"); r1.setBounds(75,50,100,30); r2.setBounds(75,100,100,30); ButtonGroup bg=new ButtonGroup(); bg.add(r1);bg.add(r2); if(r1.isSelected()){ JOptionPane.showMessageDialog(this,"You are Male.");} |
Головна > Java Swing >