查找活动/打开对话框面板 - Netbeans平台

时间:2014-07-22 05:44:43

标签: java netbeans-platform

是否有任何特定的方法来获取由代码段DialogDisplayer.getDefault().createDialog(panelDescriptor)

生成的活动/打开对话框面板

我发现WindowManager.getDefault().getRegistry().getOpened()将返回当前打开的所有TopComponents。是否有任何类似的方法可以返回打开的Dialog面板。

环境:Java 8u05 Netbenas 8.0

2 个答案:

答案 0 :(得分:0)

终于找到了解决方案: WindowManager.getDefault().getMainWindow().getOwnedWindows()将返回在主窗口下打开的对话框列表。

for (Window window : WindowManager.getDefault().getMainWindow().getOwnedWindows())
{
    // Close and dispose the dialog 
    window.setVisible(false);
    window.dispose();
}

答案 1 :(得分:0)

另一种解决方案是遍历您创建的所有框架:

for(Frame frame : Frame.getFrames())
{
    /* Find your dialog here */
}

但与之合作

WindowManager.getDefault().getMainWindow().getOwnedWindows()

在我看来更干净。

相关问题