问题
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.
回答1:
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.
回答2:
JRadioButton radioB = new JRasioButton (...);
radioB.setVerticalTextPosition(JLabel.BOTTOM);
来源:https://stackoverflow.com/questions/8669735/how-to-vertically-align-text-and-image-above-a-jradiobutton