Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6292292

Java app doesn't exit automatically when last TrayIcon is removed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • client-libs
    • b45
    • generic
    • windows
    • Verified

      A Java app has a TrayIcon displayed. Then it disposes all its toplevels and removes
      the TrayIcon from the SystemTray. No automatic shutdown will follow.

      Here's the sample code:

      import java.awt.*;
      import java.awt.image.*;

      public class SystemTrayExitTest {

      public static void main(String[] args) {
      BufferedImage im = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
               Graphics gr = im.createGraphics();
      gr.setColor(Color.red);
      gr.fillRect(0, 0, 16, 16);

      TrayIcon icon = new TrayIcon(im);
      icon.setImageAutoSize(true);

      SystemTray.getSystemTray().add(icon);

      try { Thread.sleep(2000); } catch (Exception e) {}

      System.err.println("Exiting...");

      SystemTray.getSystemTray().remove(icon);
      }
      }
      ###@###.### 2005-06-29 15:26:44 GMT

            ant Anton Tarasov (Inactive)
            ant Anton Tarasov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: