【问题标题】:Intellij toolwindow close/open or show/hide programaticallyIntellij 工具窗口以编程方式关闭/打开或显示/隐藏
【发布时间】:2014-05-14 02:09:19
【问题描述】:
我使用 Intellij 的工具窗口作为主框架。单击同一窗口中的按钮时,将打开另一个窗口 (jdialog)。当 jDialog 框打开时,我想隐藏或关闭工具窗口。而当用户点击jDialog框中的停止按钮时,我希望工具窗口再次出现。
我已经尝试将可见属性设置为false,比如
toolWindow.getComponent().setVisible(false);
这只是隐藏内容,而不是工具窗口本身。
你能建议我实现这一目标的方法吗?
【问题讨论】:
标签:
intellij-idea
visibility
show-hide
【解决方案1】:
这就是你显示/激活它的方式:
toolWindow.activate(null);
所以 hide 可能是这样的:
toolWindow.hide(null);
然后像这样关闭:
ContentManager contentManager = toolWindow.getContentManager();
contentManager.removeAllContents(true);
contentManager.dispose();
(但我没试过:))