JDK-6583251 : One more ClassCastException in Swing with TrayIcon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6,7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2007-07-20
  • Updated: 2012-10-01
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Fixed 7 b20Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
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
20-07-2007