Hide Java application to System Tray
<p>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.</p>

<p><a href="https://i.stack.imgur.com/Lo1IG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lo1IG.png" alt="image"></a></p>

<p>I tried to implement it like <a href="https://stackoverflow.com/questions/7461477/how-to-hide-a-jframe-in-system-tray-of-taskbar">this</a> and the icon did appear in the system tray but it is still showing the application on the taskbar.</p>

<p>Here is part of the Frame class</p>

<pre><code>public class Widget extends JFrame {
private static final long serialVersionUID = -197136854089859547L;
private JPanel mainPanel;
private WidgetProperties properties;
private Makedir mkdir;
private ArrayList&lt;Item&gt; 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);
}
</code></pre>

<p>}</p>

<p>I just need to find how to hide the application from the taskbar.</p>