简体   繁体   中英

java jdialog taskbar button

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);
        }
    }
}

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

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM