2

I want to hide my Java application from the taskbar and for it to be visible only at the system tray. Here is a picture in case this is unclear.

image

I tried to implement it like this and the icon did appear in the system tray but it is still showing the application on the taskbar.

Here is part of the Frame class

public class Widget extends JFrame {
private static final long serialVersionUID = -197136854089859547L;
private JPanel mainPanel;
private WidgetProperties properties;
private Makedir mkdir;
private ArrayList<Item> items;
private Image icon;
private TrayIcon trayIcon;
private SystemTray tray;

public Widget() {
    super("");
    this.setTray();
    this.setUndecorated(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void setTray() {
    tray = SystemTray.getSystemTray();
    PopupMenu menu = new PopupMenu();
    MenuItem show = new MenuItem("Show");
    MenuItem exit = new MenuItem("Exit");
    show.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            setState(Frame.NORMAL);
        }
    });
    exit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            close();
        }
    });
    menu.add(show);
    menu.addSeparator();
    menu.add(exit);
    trayIcon = new TrayIcon(icon, "EasyStart", menu);
    trayIcon.setImageAutoSize(true);
    try

    {
        tray.add(trayIcon);

    } catch (AWTException e) {
        e.printStackTrace();
    }
}

public void setup() {
    this.resize();
    this.setVisible(true);
}

public void resize() {
    this.setResizable(true);
    this.setShape(properties.getShape());
    this.setSize(properties.getSize());
    this.setResizable(false);
}

public void close() {
    System.exit(0);
}

}

I just need to find how to hide the application from the taskbar.

Community
  • 1
  • 1
nick zoum
  • 7,216
  • 7
  • 36
  • 80
  • Fairly sure if you have a window it will show up in the taskbar; the taskbar is really just a list of windows – Natecat May 09 '16 at 01:10

1 Answers1

0

do this setVisible(false) then there will be nothing in the taskbar

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150