I have a trivial swing application that is preventing windows from shutting down on Windows 7.
I have a JFrame initialized with:
I'm running the app from a shortcut that is invoking javaw.exe
I thought that this should do the trick but no luck. Any ideas?
Is there a shortcut property that I should be setting?
P.S. It does have one swing Timer in the app.
Additional info: It appears that the act of having windows shutdown the application is somehow causing an infinite loop. I've tried some new things like DISPOSE_ON_CLOSE and also sending a CLOSING event instead of calling dispose() directly. Same result. If I Cancel the shutdown when windows fails to close the application the performance meter shows that one of the CPU's cores is slammed. I have to find and kill the javaw process to get it to stop.
When Windows logs off it sends a close signal to all open windows. In your example your frame (window) is ignoring that request. If you change your default close operation to DISPOSE_ON_CLOSE or EXIT_ON_CLOSE it should end the JVM properly. If not then it is indeed a bug.
The reason it works with java is that there is an additional command prompt window. This is then closed, which causes it to end the JVM process it started.
Joined: Dec 02, 2011
Thanks for your response Rob. As the comment in my code indicates, the setting for defaultCloseOperation appears to have no bearing on the problem. I have tried all possible values, including the default (which I believe is HIDE_ON_CLOSE, but I could be wrong). The behavior is the same in all cases: i.e. program isn't terminated on shutdown/logoff.
Randall, if a (Windows) user double clicks on a .jar file, 'javaw.exe" is invoked, so that is how my users run my .jar file. I sometimes use the Command Prompt, where I can invoke either java.exe or javaw.exe.