Can someone tell me what’s wrong in the below code, I am getting syntax error in the first line.
WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
Thanks
One of two possible issues is occurring here.
1) You haven’t imported
java.awt.event.WindowEventand therefore the class cannot be found by the compiler.2) Your
thisreference does not point to an instance ofjava.awt.Window.