JCheckBoxMenuItem的刻度和JMenuItem的图像未对齐

问题描述 投票:0回答:1

我已经在菜单项中添加了图像,但是在同一菜单中,我使用了复选框项,结果对眼睛的吸引力不是很大。勾选框和图像未与其他菜单项的图像垂直对齐。我该如何解决?为什么会这样? JCheckBoxMenuItem的图像是该复选框,不是吗?

JMenu menu_project = new JMenu("Project");
menu_project.setMnemonic(KeyEvent.VK_P);
menubar.add(menu_project);

JMenuItem menuitem_setinputparam = new JMenuItem("Set input parameters");
menuitem_setinputparam.setMnemonic(KeyEvent.VK_I);
menuitem_setinputparam.addActionListener(listener);
menu_project.add(menuitem_setinputparam);

JMenuItem menuitem_showoutput = new JCheckBoxMenuItem("Show all output at the end");
menuitem_showoutput.setMnemonic(KeyEvent.VK_O);
menuitem_showoutput.addActionListener(listener);
menu_project.add(menuitem_showoutput);

menu_project.addSeparator();

JMenuItem menuitem_statistics = new JMenuItem("Statistics", new ImageIcon(this.getClass().getResource("assets/menuitem_statistics.png")));
menuitem_statistics.setMnemonic(KeyEvent.VK_S);
menuitem_statistics.addActionListener(listener);
menuitem_statistics.setToolTipText("Overview your flow.");
menu_project.add(menuitem_statistics);

Desired:

What I get:

java swing user-interface jcheckbox jmenuitem
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.