To me, the JRadioButton with icon given for constructor doesn't seem to work; it replaces the "native radio button icon" with given icon. I think to original asked wanted for radio button with icon in addition to the "radio button icon".
There has been some debate on the behaviour at Sun bug database with Bug #4177248 but no changes have been made.
Instead, one could try JRadioButtonMenuItem, even though there will probably be some non-wanted behaviour with that?
Short evaluation for both JRadioButton and JRadioButtonMenuItem:
public class IconRadioButtonEval {
public static void main(String[] args) throws Exception {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
// Use some arbitrary working URL to an icon
URL url =
new URL(
"http://mikeo.co.uk/demo/sqlspatial/Images/RSS_Icon.png");
Icon icon = new ImageIcon(url);
JRadioButton button = new JRadioButton(icon);
panel.add(new JLabel("RadioButton with icon:"));
panel.add(button);
panel.add(new JLabel("RadioButtonMenuItem with icon:"));
panel.add(new JRadioButtonMenuItem(icon));
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
Justin's suggestion for another component next to JRadioButton with empty string should probably work well in most cases.