I debugged your SSCCE, and the value passed to setPrototypeDisplayValue
is the empty string. Changing the line to
cbox.setPrototypeDisplayValue(cbox.getSelectedItem());
Makes everything work as expected. Removing the call to setPrototypDisplayValue
also makes the program behave as expected.
EDIT:
The other problem is that no event is fired for the prototype display value because you set it to the previous value as before, and an event is only fired if the value actually changes. Adding cbox.setPrototypeDisplayValue("");
before cbox.setPrototypeDisplayValue(cbox.getSelectedItem().toString())
makes everything behave as expected, even on JDK 1.6. I agree that given that the font is changed, the preferred size should be recomputed, but at least this change is a workaround.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…