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

Mouse enter and mouse exit messages are ignored

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 6, 7
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows, windows_xp

      Description

      FULL PRODUCT VERSION :
       SE Runtime Environment (build 1.6.0_02-b06)

      A DESCRIPTION OF THE PROBLEM :
      No mouse enter and mouse exit messages are shown. Only clicks work.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the given code and move the mouse over the tray icon.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "Tray Icon - Mouse entered!" and "Tray Icon - Mouse exited!" should be printed to System.out
      ACTUAL -
      nothing is printed to System.out

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.AWTException;
      import java.awt.Image;
      import java.awt.MenuItem;
      import java.awt.PopupMenu;
      import java.awt.SystemTray;
      import java.awt.Toolkit;
      import java.awt.TrayIcon;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.MouseEvent;
      import java.awt.event.MouseListener;

      import javax.swing.JFrame;

      public class TestTrayIcon extends JFrame{
      private static final long serialVersionUID = 5136100386969955560L;

      public TestTrayIcon(){
      System.out.println("<DB>TestTrayIcon.java.TestTrayIcon:1");
      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 Performed!",
      TrayIcon.MessageType.INFO);
      }
      };

      trayIcon.setImageAutoSize(true);
      trayIcon.addActionListener(actionListener);
      trayIcon.addMouseListener(mouseListener);

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

      } else {

      // System Tray is not supported
      }
      }

      public static void main(String[] args) {
      new TestTrayIcon().setVisible(true);
      }
      }

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ant Anton Tarasov
              Reporter:
              ttzhang Tao Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: