@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
validateCheckBox();
if (_uncheckImage == null) {
GraphicsConfiguration graphicsConfiguration = ((Graphics2D) g).getDeviceConfiguration();
_uncheckImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
_checkBox.setState(TristateCheckBox.STATE_UNSELECTED);
_checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
_checkBox.paint(_uncheckImage.getGraphics());
_checkedImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
_checkBox.setState(TristateCheckBox.STATE_SELECTED);
_checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
_checkBox.paint(_checkedImage.getGraphics());
_mixedImage = graphicsConfiguration.createCompatibleImage(getIconWidth(), getIconHeight(), Transparency.TRANSLUCENT);
_checkBox.setState(TristateCheckBox.STATE_MIXED);
_checkBox.setBounds(0, 0, getIconWidth(), getIconHeight());
_checkBox.paint(_mixedImage.getGraphics());
}
if (getState() == TristateCheckBox.STATE_SELECTED) {
g.drawImage(_checkedImage, x, y, null);
}
else if (getState() == TristateCheckBox.STATE_UNSELECTED) {
g.drawImage(_uncheckImage, x, y, null);
}
else if (getState() == TristateCheckBox.STATE_MIXED) {
g.drawImage(_mixedImage, x, y, null);
}
}