0

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • You really want to check if only one instance of your application is running. Refer to this SO question. [How to implement a single instance Java application?](https://stackoverflow.com/questions/177189/how-to-implement-a-single-instance-java-application) – Abra Feb 29 '20 at 14:23

1 Answers1

2

You can try:

boolean trayExists = SystemTray.getSystemTray().getTrayIcons().length > 0;
George Z.
  • 6,643
  • 4
  • 27
  • 47
  • @BulbulAhmed [What should I do when someone answers my question](https://stackoverflow.com/help/someone-answers). – George Z. Mar 01 '20 at 10:44