如何垂直对齐文本和图像上方的一个JRadioButton? [英] How to vertically align text and image above a JRadioButton?

查看:639
本文介绍了如何垂直对齐文本和图像上方的一个JRadioButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能调整文本和图像上方的一个JRadioButton 图标?

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

修改 -
那么,显然设置的图标在构造其实是将默认的一个JRadioButton 图标,这是我没想到。看起来像我可能要使用两个单独的组件,并把它们放入同一容器中。

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.

推荐答案

这将设置上面的一个JRadioButton的文字:

This will set the text above the JRadioButton:

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

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

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

这篇关于如何垂直对齐文本和图像上方的一个JRadioButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆