图标用的JRadioButtonMenuItem各种尺寸的垂直对齐 [英] Vertical alignment of icons with various size in JRadioButtonMenuItem

查看:174
本文介绍了图标用的JRadioButtonMenuItem各种尺寸的垂直对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题,以调整不同尺寸的图标,的JRadioButtonMenuItem 。 这里是我的问题的照片。图标有几种尺寸和左对齐。

I met problem to align icons of different sizes with JRadioButtonMenuItem. Here's a picture of my problem. The icons have several sizes and are left aligned.

我想中心的图标,如下面的图片。

I would like to center the icons as in the picture below.

显然,没有任何的JRadioButtonMenuItem类的方法允许这样做...

Apparently, none of the methods of JRadioButtonMenuItem class allow to do that...

推荐答案

作为一种替代方法,使用恒定的封闭尺寸落实图标接口和规模呈现的内容,以反映所需的图像尺寸,如本示例的。为方便起见,可以渲染任意大小单code字形,如图这里

As an alternative, implement the Icon interface using a constant enclosing size and scale the rendered content to reflect the desired image size, as shown in this example. For convenience, you can render arbitrary sized unicode glyphs, as shown here.

这篇关于图标用的JRadioButtonMenuItem各种尺寸的垂直对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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