Why does my Swing window keep closing itself after a few seconds?

给你一囗甜甜゛ 提交于 2019-12-04 14:04:31

I suggest the following strategy to learn more about the problem:

sun.awt.AWTAutoShutdown is the class that prevents shutdown of the JVM if a native window peer is registered with the toolkit. Any component is registered when addNotify() is called on it. For a frame, this is done when you call setVisible(true).

The only way a peer can get unregistered is if somebody calls dispose() on the peer. The only place dispose() is called on a peer in the JRE is from Component#removeNotify().

You could override that method in your frame class and print a stack trace to see why that happens.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!