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

Popup not showing when tray icon right click

XMLWordPrintable

    • x86
    • windows_2008

      FULL PRODUCT VERSION :
      jdk 1.7 to till current versions.
      used version jre 1.7_0.71


      ADDITIONAL OS VERSION INFORMATION :
      Windows Server 2008 R2 standard. 64-bit operation system
      Citrix environment
      Xenapp 6.5 version.

      A DESCRIPTION OF THE PROBLEM :
      By using citrix environment/webpage we are launching the java applications.
      For java application we have added tray icon, popupmenu set the for the trayicon.
      When launch the application, trayicon is not showing the popupmenu by right click.

      REGRESSION. Last worked in version 6u43

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.6.0_27"
      Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
      Java HotSpot(TM) Client VM (build 20.2-b06, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      simple java application
      add the popup menu to tray icon.
      add the tray icon
      launch the application, right click on tray icon.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      TrayIcon popup menu will not appear when right click on tray icon.
      ACTUAL -
      Tray icon right click popup menu should show.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.AWTException;
      import java.awt.BorderLayout;
      import java.awt.Dimension;
      import java.awt.Image;
      import java.awt.MenuItem;
      import java.awt.PopupMenu;
      import java.awt.SystemTray;
      import java.awt.TrayIcon;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.net.URL;

      import javax.swing.ImageIcon;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JMenuItem;
      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;

      public class TrayIconDemo
      {

          private final static SystemTray tray = SystemTray.getSystemTray();

          private static TrayIcon trayIcon;

          public static void main(String[] args)
          {
              URL javaCupIconUrl = Class.class
                      .getResource("/javax/swing/plaf/basic/icons/JavaCup16.png");
              Image trayImage = new ImageIcon(javaCupIconUrl).getImage();

              JButton testBtn = new JButton("Test System Tray Message1");
              final JFrame frame = new JFrame("testTrayIcon");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JLabel label = new JLabel(
                      "Successfully clicking the icon will launch espn.com");
              final JPanel panel = new JPanel(new BorderLayout());
              panel.add(testBtn , BorderLayout.NORTH);
              panel.add(label , BorderLayout.CENTER);
              frame.setSize(new Dimension(500 , 100));
              frame.add(panel);
              frame.setVisible(true);
              PopupMenu menu = new PopupMenu();
              MenuItem item = new MenuItem("showOptionPane");
              item.addActionListener(new ActionListener()
              {
                  public void actionPerformed(ActionEvent e)
                  {
                      JOptionPane.showMessageDialog(frame , "shown the prompt");
                  }
              });
              menu.add(item);
              trayIcon = new TrayIcon(trayImage , "Kaither App" , menu);

              trayIcon.addActionListener(new ActionListener()
              {

                  @Override
                  public void actionPerformed(ActionEvent e)
                  {
                      frame.toFront();
                      frame.setVisible(true);
                  }
              });

              SwingUtilities.invokeLater(new Runnable()
              {
                  public void run()
                  {
                      try
                      {
                          tray.add(trayIcon);
                      }
                      catch (AWTException e)
                      {
                          System.out.println(e.getStackTrace());
                      }
                  }
              });
          }
      }

      ---------- END SOURCE ----------

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: