问题描述
我当前的设计是这样的:我有一个显示主应用程序的外框.当用户单击主应用程序上的按钮时,应启动一个弹出窗口.我正在使用JOptionPane.showInternalOptionDialog并将按钮对象作为选项传递.当用户单击这些按钮之一时,它应运行某些命令,然后关闭该窗口.我无法关闭显示弹出窗口的框架.
My current design is like this:I have an outer frame that displays main app. When user clicks a button on the main app, a pop-up Window should be launched. I am using JOptionPane.showInternalOptionDialog and passing button objects as options. When user clicks one of these button, it should run certain commands and then close the window. I was not able to close the Frame that shows the pop-up.
我在该论坛中发现了一个类似的问题,建议采取以下解决方法.关闭由JOptionPane.showOptionDialog()创建的对话框
I found a similar question in this forum, that suggests the following workaround.Closing a dialog created by JOptionPane.showOptionDialog()
但是上述解决方法关闭了我的完整GUI.我只想关闭JOptionPane弹出窗口.
But the above workaround closes my complete gui. I just want to close the JOptionPane popup.
谢谢.
推荐答案
尝试
JOptionPane.getRootFrame().dispose();
在事件中
这篇关于以编程方式关闭JOptionPane.ShowInternalOptionDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!