United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6583251 One more ClassCastException in Swing with TrayIcon
JDK-6583251 : One more ClassCastException in Swing with TrayIcon

Details
Type:
Bug
Submit Date:
2007-07-20
Status:
Closed
Updated Date:
2012-10-01
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
client-libs
OS:
generic,windows_xp
Sub-Component:
javax.swing
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6,7
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

Description
Before JDK 6 all MouseEvents were generated by subclasses of awt.Component
so it was safe to cast mouseEvent.getSource() to awt.Component,
now it's not the case, because TrayIcon can generate MouseEvents
and TrayIcon doesn't extends awt.Component
so we get ClassCastException from several places

like BasicPopupMenu.MouseGrabber.eventDispatched(AWTEvent ev)

where we do Component src = (Component)ev.getSource();

we should fix it and not cast ev.getSource() without checking

                                    

Comments
EVALUATION

Everything is clear
we shouldn't cast mouseEvent.getSource() to Component
without checking
                                     
2007-07-20



Hardware and Software, Engineered to Work Together