how do you see if a button is selected or not and use it as a binary value
i have 3 radio buttons b1, b2, b3, they are all separate (not in a ButtonGroup), i need that when the user hits submit i can save the binary value (true if pressed, false if not pressed) into a variable
//Gets details when submit is pressed
submit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String name = t.getText();
String surname = t1.getText();
String studentID = t2.getText();
//Code to place binary values into variables depending on the radio buttons selected
}
});
If you are talking about a
JRadioButton, you can use theisSelected()method to know whether the user checked it or not.