I have a problem while compiling a simple program. I started using Swing library two days ago, so i'm not good enough yet. The error is: "non-static variable this cannot be referenced from a static context", referred to "WindowsEraser listener = new WindowsEraser();". What is the problem?
public class prog9{
public class WindowEraser extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
public static void main(String[] args){
JFrame frame = new JFrame("Frame with buttons");
frame.setSize(400,400);
JLabel label = new JLabel("I'm a Window");
frame.add(label);
WindowEraser listener = new WindowEraser();
frame.addWindowListener(listener);
frame.setVisible(true);
}
}