I am a beginning programmer. Posting a small portion of a GUI application I have created. The problem is that I want the group of Radio buttons and some text boxes to be clear when a button is clicked but the button group is not accessible from within the actionListener for the button. I understand the problem of scope very well but it is necessary to perform this action through the button. Please help me.
ButtonGroup bg = new ButtonGroup();
bg.add(rbtn1);
bg.add(rbtn2);
bg.add(rbtn3);
bg.add(rbtn4);
JButton clrBtn= new JButton("Clear");
clrBtn.setForeground(SystemColor.textHighlight);
clrBtn.setFont(new Font("Verdana", Font.BOLD, 18));
clrBtn.setBounds(198, 353, 98, 36);
frame.getContentPane().add(clrBtn);
clrBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String v = "";
textField.setText(v);
textField_1.setText(v);
textField_2.setText(v);
txtKdfj.setText(v);
}
});