I have to make three radio buttons. On selection of the third radio button I have to show some text boxes. I also have to immediately remove the text boxes when the third radio button is unselected and any one of the other two is selected. I am looking for a callback when the JRadio button is unselected. I have supplied an ActionListener but it gets called only on selection and not on unselection. How do I achieve this toggle functionality with java JRadio button.
radioCustomButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Callback called");
if(radioCustomButton.isSelected()){
System.out.println("Checked");
}
}
});
This is printing "Callback called" only on check but not on uncheck. I have added this radioCustomButton object in ButtonGroup as well.
I am left with the only option of supplying action listener to other two radio buttons and then write code to remove the text boxes.