I am trying to use an inner class setup, however I'm having some problems. This is the code I'm trying to use:
public class GUI
{
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// do something
}
}
private static void someMethod()
{
JButton button = new JButton( "Foo" );
button.addActionListener(new ButtonHandler());
}
}
This is the error message I'm getting (in eclipse):
No enclosing instance of type GUI is accessible. Must qualify the allocation with an enclosing instance of type GUI (e.g. x.new A() where x is an
instance of GUI).
Please can someone help me out?