0

Is it possible to align both the text and image above the JRadioButton icon?

Edit -
Well, apparently setting the icon in the constructor actually replaces the default JRadioButton icon, which I wasn't expecting. Looks like I may have to use two separate components and throw them into the same container.

mre
  • 43,520
  • 33
  • 120
  • 170
  • The UI delegate uses the icon. Would a `ButtonGroup` of `JToggleButton` with custom icon be an alternative? – trashgod Dec 29 '11 at 17:35

2 Answers2

3

This will set the text above the JRadioButton:

radiobutton.setHorizontalTextPosition(SwingConstants.CENTER);
radiobutton.setVerticalTextPosition(JRadioButton.TOP);

And yes, using the setIcon method replaces the JRadioButton icon.

Katana
  • 745
  • 2
  • 5
  • 7
0
JRadioButton radioB = new JRasioButton (...);

radioB.setVerticalTextPosition(JLabel.BOTTOM);
Adi Mor
  • 2,145
  • 5
  • 25
  • 44