I want to replace the text in my radio button list by an icon.
I've tried this:
rotateButton = new JRadioButton(rotateIcon.getImage());
But this replaces the radio button and text by the icon. I would like to keep the radio button and display the image.
What should I do?
What I'm currently getting is:
But I want it to end up with this:
Create a JRadioButton with no text and put a JLabel with the image next to it. You can also create a class to hide complexity.
public JRadioButton(String text, Icon icon) and simple example here
There is no radio button constructor that allows an image as the content argument instead of a text. The only way to replace the text of a radio button by an image it is generate html and pass it as an argument to the default constructor.
I just reproduced your described behavior using this source:
It seems like a bug to me, though I cannot recall seeing a radio with an icon. How are they supposed to look?
Time to reach into my 'box of hacks'.
This technique will not work if: