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

Even more ClassCasetException with TrayIcon

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • client-libs
    • None
    • b27
    • generic
    • generic

        There is one more place when we unsafely cast MouseEvent.getSource() to Component
        and get ClassCastException is the source of the event is TrayIcon
        (TrayIcon doesn't extend awt.Component)

        Test to reproduce is here:
        https://swinghelper.dev.java.net/source/browse/swinghelper/src/java/org/jdesktop/swinghelper/tray/JXTrayIcon.java?view=markup

        For some reason it is reproduced only on Linux machines

        Run this demo and click the red icon in the tray area

        You'll have -

        Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: JXTrayIcon1 cannot be cast to java.awt.Component
                at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:204)
                at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.eventDispatched(BasicPopupMenuUI.java:817)
                at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2353)

              mlapshin Mikhail Lapshin (Inactive)
              alexp Alexander Potochkin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: