我已经将带有html applet标签的applet启动迁移到带有applet描述符的jnlp部署。
使用applet解决方案,当浏览器窗口关闭时,java应用程序结束。
使用JNLP解决方案,当窗口关闭时,java应用程序不会停止。 并引发了异常:
Plugin2Manager calling stopFailed() because of exception during AppContext.dispose()
Plugin2Manager calling stopFailed() because of displayable window javax.swing.JFrame[frame0,240,1,1018x647,invalid,hidden,layout=java.awt.BorderLayout,title=TimeCheck,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,3,32,1012x612,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
Exception in thread "Thread-19" java.lang.NullPointerException
at sun.plugin2.applet.Plugin2Manager.destroyAppContext(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.destroyAppContext(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.cleanupAppContext(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.shutdownAppContext(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.stop(Unknown Source)
at sun.plugin2.applet.viewer.JNLP2Viewer$2$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
非常感谢。
答案 0 :(得分:0)
解决方案是将WindowListener添加到topLevel框架。一旦我们拥有TopLevel框架,也可以设置Resizable。
....
while (parent.getParent() != null)
parent = parent.getParent();
if (parent instanceof Frame) {
((Frame) parent).setResizable(true);
((Frame) parent).addWindowListener(this);
}
....
close事件的事件处理程序将执行System.exit();
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}