user3360927
user3360927

Reputation: 35

Correct syntax for disabling a radio button after it was chosen

is it possible to disable a radio button? after a user chooses one of the radio buttons , i don't want them changing answers so i want to disable the radio button, i've used

radioButton.setEnable(false)

but still it's able to choose other radio buttons.

What is the correct syntax in disabling a radio button after it was chosen?

Upvotes: 2

Views: 556

Answers (1)

rpax
rpax

Reputation: 4496

 JRadioButton b1 = new JRadioButton("");
 b1.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
     if ("disable".equals(e.getActionCommand())) {
      b1.setEnabled(true);
       } else {
        b1.setEnabled(false);
       }
    }
    });

Upvotes: 1

Related Questions