Search code examples
javaswingsystem-tray

How to check The System tray is already exists or not?


Is there any way that I can check if a system tray already exists? When I keep running the program to create a system tray then multiple occurrences appear, which means multiple programs are running. So, I need to check the system tray is already there?


Solution

  • You can try:

    boolean trayExists = SystemTray.getSystemTray().getTrayIcons().length > 0;