java jdialog 任务栏按钮

发布于 2024-09-14 04:56:27 字数 494 浏览 3 评论 0原文

我正在 Linux 上托盘 jdialog,但它仍然出现在我的任务栏中。 这是代码?怎么了?

import javax.swing.JDialog;

public class Main {
    public static void main(String [] args) {
        new mydialog();
    }

    private static class mydialog extends JDialog {
        public mydialog() {
            super();
            setSize(200,200);
            setLocationByPlatform(true);
            setAlwaysOnTop(false);
            setUndecorated(true);
            setVisible(true);
        }
    }
}

i'm traying a jdialog on linux, but it still appears in my taskbar.
this is the code? what's wrong?

import javax.swing.JDialog;

public class Main {
    public static void main(String [] args) {
        new mydialog();
    }

    private static class mydialog extends JDialog {
        public mydialog() {
            super();
            setSize(200,200);
            setLocationByPlatform(true);
            setAlwaysOnTop(false);
            setUndecorated(true);
            setVisible(true);
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

谜兔 2024-09-21 04:56:27

由于这在 Linux 环境中似乎仍然是一个问题,我想分享我对此主题的解决方案:

我只需使用父框架/窗口创建 JDialog,如“new JDialog(new JFrame());”将 JDialog 设置为可见后,我调用“jframe.revalidate();”。就是这样。看起来 Java 在初始化 JDialog 时与 DisplayManager 正确通信时出现问题。

适用于 Java 1.8.0.45、Linux Mint 17.1、Cinnamon 2.4.8

Since this still seems to be an issue in Linux environments I'd like to share my solution for this topic:

I simply had to create the JDialog with an parent Frame/Window like "new JDialog(new JFrame());" and after setting the JDialog to be Visible I call "jframe.revalidate();". Thats it. Looks like Java has a problem communicating correctly with the DisplayManager while initialising the JDialog..

Works for me with Java 1.8.0.45, Linux Mint 17.1, Cinnamon 2.4.8

鸠魁 2024-09-21 04:56:27

尝试将 setLocationByPlatform(true); 替换为 setLocation(10, 10);

try replacing setLocationByPlatform(true); with setLocation(10, 10);

画骨成沙 2024-09-21 04:56:27

如果您不希望它出现在任务栏中,则需要使用 JWindow。
另请参阅:how-do-i-prevent-jdialog -来自在 gnome-panellinux 中显示

You need to use JWindow if you don't want it to appear in the taskbar.
See also: how-do-i-prevent-jdialog-from-showing-in-gnome-panellinux

把时间冻结 2024-09-21 04:56:27

我找到的唯一解决方案是从 Swing 界面切换到 gtk 界面,为此我使用了 java-gnome。唯一的问题是您必须将 swing 类的所有组件更改为相应的 gtk 类。

the only solution I found is to switch from Swing interfaces to gtk interfaces, to do this I used java-gnome. the only problem is that you must change all components of the swing classes to the corresponding gtk classes.

慵挽 2024-09-21 04:56:27

一段时间以来一直在与这个问题斗争。最终对我有用的是:

JDialog frame = new JDialog();
frame.setType(javax.swing.JFrame.Type.POPUP);

或者您可以尝试将类型设置为 UTILITY。

运行 Java 1.8.0_25 的 Lubuntu 15.04 (LXDE)

Been struggling with this one for some time now. What finally worked for me:

JDialog frame = new JDialog();
frame.setType(javax.swing.JFrame.Type.POPUP);

Alternatively you can try set the type to UTILITY.

Lubuntu 15.04 (LXDE) running Java 1.8.0_25

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文