I've created a JRadioButton subclass in which I override the paintComponent method like so:
@Override
protected void paintComponent(Graphics g) {
g.drawImage(
isSelected() ?
getCheckedImg() :
getBasicImg()
, 0, 0, this);
}
but it seems that once the button is drawn, that's the image it uses forever. The isSelected test doesn't seem to have any effect. Are the graphics cached or something by Java? How do I provide my custom JRadioButton with a selected and unselected image? Do I have to write a custom UI?