Java 如何在JRadioButton上方垂直对齐文本和图像?

Java 如何在JRadioButton上方垂直对齐文本和图像?,java,swing,alignment,jradiobutton,Java,Swing,Alignment,Jradiobutton,是否可以将JRadioButton图标上方的文本和图像对齐 编辑- 显然,在构造函数中设置图标实际上替换了默认的JRadioButton图标,这是我没有想到的。看起来我可能需要使用两个单独的组件并将它们放入同一个容器中。这将在JRadioButton上方设置文本: JRadioButton radioB = new JRasioButton (...); radioB.setVerticalTextPosition(JLabel.BOTTOM); radiobutton.setHorizon

是否可以将
JRadioButton
图标上方的文本和图像对齐

编辑-

显然,在构造函数中设置图标实际上替换了默认的
JRadioButton
图标,这是我没有想到的。看起来我可能需要使用两个单独的组件并将它们放入同一个容器中。

这将在JRadioButton上方设置文本:

JRadioButton radioB = new JRasioButton (...);

radioB.setVerticalTextPosition(JLabel.BOTTOM);
radiobutton.setHorizontalTextPosition(SwingConstants.CENTER);
radiobutton.setVerticalTextPosition(JRadioButton.TOP);

是的,使用setIcon方法替换JRadioButton图标。

这将设置JRadioButton上方的文本:

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

是的,使用setIcon方法替换JRadioButton图标。

UI委托使用该图标。带有自定义图标的
JToggleButton
ButtongGroup
是否可以替代?UI代理使用该图标。带有自定义图标的
JToggleButton
ButtongGroup
会是一个替代方案吗?