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

TrayIcon right click popup menu doesn't show up in java7b115 afterward

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b120)
      Java HotSpot(TM) Client VM (build 17.0-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP3 32bit

      A DESCRIPTION OF THE PROBLEM :
      We find that TrayIcon popup menu seem have some problem in latest java7 b120, We use the following class to test. http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/. We can see that on java6 and java7 b72 the TrayIcon popup menu function property. But with java7 b115 to b120, the popup menu doesn't showup. Is the TrayIcon popup function going to have big change?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/
      We use this class to test TrayIcon function
      1. After compile and run should see a TrayIcon on the bottom-right taskBar area
      2. Then we right click the TrayIcon with mouse over it

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expected result is when right click on TrayIcon, a popup menu should show up for user select.
      ACTUAL -
      No popup menu showup and no exception received

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No exception received

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Copyright 2005 Sun Microsystems, Inc. ALL RIGHTS RESERVED
       * Use of this software is authorized pursuant to the terms of the
       * license found at http://developers.sun.com/berkeley_license.html
       *
       */

      package systemtray;

      import java.awt.*;
      import java.awt.event.*;

      public class SystemTrayTest
      {
          
          public SystemTrayTest()
          {
              
              final TrayIcon trayIcon;

              if (SystemTray.isSupported()) {

                  SystemTray tray = SystemTray.getSystemTray();
                  Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");

                  MouseListener mouseListener = new MouseListener() {
                      
                      public void mouseClicked(MouseEvent e) {
                          System.out.println("Tray Icon - Mouse clicked!");
                      }
                      public void mouseEntered(MouseEvent e) {
                          System.out.println("Tray Icon - Mouse entered!");
                      }
                      public void mouseExited(MouseEvent e) {
                          System.out.println("Tray Icon - Mouse exited!");
                      }
                      public void mousePressed(MouseEvent e) {
                          System.out.println("Tray Icon - Mouse pressed!");
                      }
                      public void mouseReleased(MouseEvent e) {
                          System.out.println("Tray Icon - Mouse released!");
                      }

                  };

                  ActionListener exitListener = new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          System.out.println("Exiting...");
                          System.exit(0);
                      }
                  };
                  
                  PopupMenu popup = new PopupMenu();
                  MenuItem defaultItem = new MenuItem("Exit");
                  defaultItem.addActionListener(exitListener);
                  popup.add(defaultItem);

                  trayIcon = new TrayIcon(image, "Tray Demo", popup);

                  ActionListener actionListener = new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          trayIcon.displayMessage("Action Event",
                              "An Action Event Has Been Peformed!",
                              TrayIcon.MessageType.INFO);
                      }
                  };
                  
                  trayIcon.setImageAutoSize(true);
                  trayIcon.addActionListener(actionListener);
                  trayIcon.addMouseListener(mouseListener);

                  // Depending on which Mustang build you have, you may need to uncomment
                  // out the following code to check for an AWTException when you add
                  // an image to the system tray.

                  // try {
                            tray.add(trayIcon);
                  // } catch (AWTException e) {
                  // System.err.println("TrayIcon could not be added.");
                  // }

              } else {
                  System.err.println("System tray is currently not supported.");
              }
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args)
          {
              SystemTrayTest main = new SystemTrayTest();
          }
          
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use jre 6 or jdk7 b72

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: