- All Implemented Interfaces:
- Icon
- Enclosing class:
- UIManagerDefaultsViewer
public static class UIManagerDefaultsViewer.SafeIcon
extends Object
implements Icon
Thanks to Jeanette for the use of this code found at:
https://jdnc-incubator.dev.java.net/source/browse/jdnc-incubator/src/
kleopatra
/java/org/jdesktop/swingx/renderer/UIPropertiesViewer.java?rev=1.2
&view=markup
Some ui-icons misbehave in that they unconditionally class-cast to the
component type they are mostly painted on. Consequently they blow up if
we are trying to paint them anywhere else (f.i. in a renderer).
This Icon is an adaption of a cool trick by Darryl Burke found at
http://tips4java.wordpress.com/2008/12/18/icon-table-cell-renderer
The base idea is to instantiate a component of the type expected by the
icon, let it paint into the graphics of a bufferedImage and create an
ImageIcon from it. In subsequent calls the ImageIcon is used.