Search code examples
javaswingjradiobutton

JRadioButton: how to replace text by IconImage?


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:

Enter image description here

But I want it to end up with this:

Enter image description here


Solution

  • public JRadioButton(String text, Icon icon) and simple example here