How can I change the label of a JRadioButton when it is set as final?
This is a section of code from the constructor where the radio buttons are initialised, when the check button is pressed, the selected radio button's value is sent to a method which verifies the user's answer:
final JRadioButton ANSWER1 = new JRadioButton("Empty 1");
final JRadioButton ANSWER2 = new JRadioButton("Empty 2");
final JRadioButton ANSWER3 = new JRadioButton("Empty 3");
final JRadioButton ANSWER4 = new JRadioButton("Empty 4");
JButton CHECK = new JButton("Check");
CHECK.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
if (ANSWER1.isSelected()){
qAnswered(1);
}
if (ANSWER2.isSelected()){
qAnswered(2);
}
if (ANSWER3.isSelected()){
qAnswered(3);
}
if (ANSWER4.isSelected()){
qAnswered(4);
}
}
});
When the next question button is selected, the text labels of the radio buttons need to change to the next set of answers. Unfortunately, because the radio buttons are set to final this causes a the application to crash.
How can I proceed?