I am a first time user of Java swing and this is the first time I'm trying to use a private class.
I am trying the following code -
ActionListener listener = new AddButtonListener();
Where AddButtonListener is a private class that implements the ActionListener interface.
private class AddButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
....
}
}
However, I am getting an eclipse error that reads
No enclosing instance of type someType is accessible. Must qualify the allocation with an enclosing instance of type someType (e.g. x.new A() where x is an instance of someType).
Note that the class is being instantiated in a static main method inside someType.
Why is this error coming up? Is it because the main method is static?