在JPopupmenu中对齐图标和JCheckbox [英] Align icon and JCheckbox in JPopupmenu

查看:181
本文介绍了在JPopupmenu中对齐图标和JCheckbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JPopupMenu 中遇到了一些图标和复选框的问题。复选框和图标未对齐

I have a Problem with some icons and check-boxes in a JPopupMenu. The Check-boxes and Icons are not aligned

项目创建如下:

JMenuItem deleteAttributeMenuItem = new JMenuItem(locale.getString("TREE_AttrDelete"), iconDelete);

JMenuItem primaryKeyAttributeMenuItem = new JCheckBoxMenuItem(locale.getString("TREE_AttrChkBoxPK"));

请看一下图片:

任何提示?

推荐答案

看看这个,为了实现你想要的,我做到了,

Have a look at this, in order to achieve what you wanted, I did this,

JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Check Me", null, true);
cbmi.setMargin(new java.awt.Insets(5, 25, 5, 5));
cbmi.setIconTextGap(15);
cbmi.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
helpMenu.add(cbmi);

以下是所述东西的输出:

And here is the OUTPUT of the said thingy :

这篇关于在JPopupmenu中对齐图标和JCheckbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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