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

java.lang.NullPointerException: Cannot invoke "java.awt.Component.isShowing()" when clicking on TrayIcon.setPopupMenu(null)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17, 19, 20, 22, 23
    • client-libs
    • x86
    • os_x

      I am getting a following exception when I click multiple times around SystemTray Icon area after setting TrayIcon.setPopupMenu(null)

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.awt.Component.isShowing()" because "srcComponent" is null
      at java.desktop/java.awt.LightweightDispatcher.eventDispatched(Container.java:4795)
      at java.desktop/java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2193)
      at java.desktop/java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2041)
      at java.desktop/java.awt.TrayIcon.dispatchEvent(TrayIcon.java:735)
      at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:780)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
      at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
      at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
      at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

      TestCase : Check whether popup is not seen when user click(s) on the trayIcon after invoking TrayIcon.setPopupMenu(null)
      https://docs.oracle.com/en/java/javase/22/docs/api/java.desktop/java/awt/TrayIcon.html#setPopupMenu(java.awt.PopupMenu)

      Step to reproduce
      -------------------------
      1) Run the attached testcase
      2) You see a black square TrayIcon on the SystemTray & Frame with One Choice & a Button.
      3) Click on the TrayIcon ( rectangle black color) on the SystemTray , also observe that trayIcon is placed inside a gray color rectangle of the popup.
      3) Mouse the move on the TrayIcon, you see a gray color around the black TrayIcon.
      4) Click on the left side of the gray area of the TrayIcon. You see a popup, select any of the popup menuitem
      5) Click on the black rectangle of the trayIcon You see a popup, select any of the popup menuitem
      6)Click on the right side of the gray area of the TrayIcon. You see a popup, select any of the popup menuitem
      7) Now Click on the Choice & select null item & Click on the button.
      8) Move the mouse pointer on the Black rectangle of the trayicon . Observe that gray color around the black rectangle is not seen any more.
      9) Click on the trayIcon & Popup should not be seen.
      10) Repeat step(4) multiple times. If you see the Exception , then the bug is reproduced


      Platform: MacOS x64 14.3.1

            kizune Alexander Zuev
            landrews Lawrence Andrews
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: