Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JFrame remove taskbar Icon

Tags:

java

swing

I have a JFrame that I minimize to the tray using:

This for showing:

Frame.this.Minimized = false;
Frame.this.setVisible(true);
systemTray.remove(systemTrayIcon);
Frame.this.setExtendedState(JFrame.NORMAL);

And this for hiding:

if (SystemTray.isSupported()) {
    systemTray.add(systemTrayIcon);
    Frame.this.setVisible(false);
    Frame.this.Minimized = true;
}
Frame.this.setExtendedState(JFrame.ICONIFIED);

However, I do NOT want to set the frame invisible.. When I set it invisible, it removes the taskbar icon which I like. Is there a way to remove the taskbar icon of the frame without setting the visibility to false?

The reason is because when I minimize my application, I can send it commands and it executes them but the second that I set its visibility to false, it stops executing any commands from an external application. All I need to do is remove the icon from the taskbar when minimized and show the icon when normal.

Any ideas?

like image 787
Brandon Avatar asked Jun 21 '13 06:06

Brandon


People also ask

How to remove java icon from JFrame?

You can set the image icon to a transparent image which will remove the coffee cup. I don't believe it is possible to get rid of the default icon otherwise. Show activity on this post. You could just use gimp or photoshop or even paint and create a 1x1px, transparent image, export it (.

How do I change the JFrame icon in Netbeans?

The method setIconImage() of the JFrame class is used to change the icon of JFrame or JWindow. It changes the icon that is displayed on the left side of the window. The Toolkit class is used to get an instance of the Image class in AWT and Swing.


1 Answers

I know this is VERY late, but I spent a good hour trying to figure this out myself. All you have to do is change your JFrame to a JWindow and you're done. I had a fairly complex JFrame and the only things I had to remove were setUndecorated() and setDefaultCloseOperation(). everything else worked just fine.

like image 129
Chris Avatar answered Sep 20 '22 09:09

Chris