gpt4 book ai didi

java - 在 HIDE_ON_CLOSE 之后显示 FrameView

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:00:05 24 4
gpt4 key购买 nike

我的 Java 应用程序有问题,我在托盘栏中设置了减少图标的必要条件并设置:

app.getMainFrame().setDefaultCloseOperation(HIDE_ON_CLOSE);

因此,当我关闭任务栏中的应用程序时,应用程序将关闭,但应用程序会继续运行,并且任务栏图标可见。

问题是:如何从任务栏恢复应用程序?

我试过:

app.show(app.getMainView().getFrame());
app.getMainView().getFrame().setVisible(true);
app.getMainView().getFrame()setVisible(true);

但它们都不起作用。

最佳答案

您需要将其恢复到默认状态:

app.getMainFrame().setVisible(true);
app.getMainFrame().setState(Frame.NORMAL);

编辑:使用 JFrame 对此进行了测试,它工作正常。见:

JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
while (true) {
f.setVisible(true);
f.setState(JFrame.NORMAL);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

这基本上只显示隐藏的 JFrame

关于java - 在 HIDE_ON_CLOSE 之后显示 FrameView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8145169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com