I am creating a WindowBuilder GUI and need to pass a variable created with a radio button to an EventHandler class to use in further processing. The output of the radio button event is successful; however, the variable "df", which is declared in the actionPerformed method in not resolved in the EventHanler class. Any help will be appreciated.
public TestClass() {
/* INSERT RADIOBUTTON INTO FRAME. */
JRadioButton rdbtnNo = new JRadioButton("No");
rdbtnNo.setFont(new Font("Tahoma", Font.BOLD, 12));
rdbtnNo.setBounds(332, 509, 63, 23);
frame.getContentPane().add(rdbtnNo);
/* LISTEN FOR RADIOBUTTON BUTTON. */
rdbtnNo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
System.out.println(command);
int df = 20;
}
});
rdbtn.setActionCommand("event");
rdbtn.addActionListener(new EventHandler());
}
public class EventHandler implements ActionListener {
public void actionPerformed(ActionEvent event) {
System.out.println(df);
}
}