Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6717617
Votes 0
Synopsis Nimbus L&F: Regression - Using ComboBox border on TextField causes ClassCastException
Category java:classes_swing
Reported Against b22
Release Fixed 6u10(b27)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6717853
Submit Date 21-JUN-2008
Description
There is a fairly odd use case which isn't entirely understood to be supported, but which was working and is now broken. The idea is that:

JComboBox cb = new JComboBox();
JTextField tf = new JTextField();
tf.setBorder(cb.getBorder());

Ends up throwing a ClassCastException. The problem is that the border on JComboBox under a Synth based look and feel is a SynthBorder, which maintains a reference to the UI that created it (SynthComboBoxUI in this case). When it is time to paint the border, it asks the UI for the Synth state. This ends up calling a private method on SynthComboBoxUI to determine the state. It would be reasonable to assume that such a private method in SynthComboBoxUI would only deal with SynthComboBoxUI's --- but in the above sequence this assumption is violated and a JTextField is passed to the internal SynthComboBoxUI method instead.

The fix is simply to put a class check back into SynthComboBoxUI. A more correct fix in Java 7 would be to fix SynthBorderUI so that if the UI didn't match the UI of the current component, then it wouldn't ask for the synth state (and thus avoid the problem entirely).
Posted Date : 2008-06-21 01:22:57.0
Work Around
N/A
Evaluation
Evaluation is as described in description
Posted Date : 2008-06-21 01:24:41.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang