本文介绍了JMenuItem显示左边的复选框,如何禁用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个下拉菜单,它驻留在程序菜单栏,并弹出一个JPopupMenu如果JButton被点击。在JPopupMenu有多个JMenuItems。



但是,在每个JMenuItem它显示一个复选框!其格式如下:



我不认为它应该,并有明确的JCheckBoxMenuItem。



有人知道为什么一个复选框出现在JMenuItem中,如何禁用/删除它?



代码

  ImageIcon icon = ViewUtilities.createIcon(resource / gui / mainMenu.png,_buttonLength); 
setIcon(icon);

JMenuItem menuItem = new JMenuItem(New Whiteboard);
menuItem.addActionListener(new NewWhiteboardActionListener());
getMenu()。add(menuItem);

menuItem = new JMenuItem(Open ...);
menuItem.addActionListener(new OpenFileActionListener());
getMenu()。add(menuItem);

menuItem = new JMenuItem(Preferences ...);
menuItem.addActionListener(new PreferencesActionListener());
getMenu()。addSeparator();
getMenu()。add(menuItem);

menuItem = new JMenuItem(Exit);
menuItem.addActionListener(new ExitActionListener());
getMenu()。addSeparator();
getMenu()。add(menuItem);

其中 getMenu()返回 JPopupMenu



谢谢!




Shuo






编辑:我已解决问题。问题出在图书馆。我使用它
为TabbedPanel的自定义LAF。只要加载弹出菜单
,它也会注入 LAF。



因此,解决方案太过设定不要载入选单样式。

  LookAndFeelFactory.installJideExtension(
LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);


解决方案

问题出现在库。我使用它
为TabbedPanel的自定义LAF。只要加载弹出菜单
,它也会注入 LAF。



因此,解决方案太过设定不要载入选单样式。

  LookAndFeelFactory.installJideExtension(
LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);


I'm building a drop down menu which resides in program menu bar and pops up a JPopupMenu if a JButton gets clicked. In the JPopupMenu there are multiple JMenuItems.

However, beside every JMenuItem it shows a checkbox! Which looks like this:

I don't think it should, and there is explicit JCheckBoxMenuItem for that.

Does anyone know why a check box appears in a JMenuItem and how do I disable / remove it?

The code

ImageIcon icon = ViewUtilities.createIcon("resource/gui/mainMenu.png", _buttonLength);
setIcon(icon);

JMenuItem menuItem = new JMenuItem("New Whiteboard");
menuItem.addActionListener(new NewWhiteboardActionListener());
getMenu().add(menuItem);

menuItem = new JMenuItem("Open...");
menuItem.addActionListener(new OpenFileActionListener());
getMenu().add(menuItem);

menuItem = new JMenuItem("Preferences...");
menuItem.addActionListener(new PreferencesActionListener());
getMenu().addSeparator();
getMenu().add(menuItem);

menuItem = new JMenuItem("Exit");
menuItem.addActionListener(new ExitActionListener());
getMenu().addSeparator();
getMenu().add(menuItem);

where getMenu() returns a JPopupMenu.

Thanks!

Cheers,
Shuo


Edit: I've fixed it. The problem is on Jide library. I've used itfor a custom LAF of TabbedPanel. And it injects LAF for popup menustoo as long as it's load.

So the solution is too set it to don't load menu styles.

LookAndFeelFactory.installJideExtension(
  LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);
解决方案

The problem is on Jide library. I've used itfor a custom LAF of TabbedPanel. And it injects LAF for popup menustoo as long as it's load.

So the solution is too set it to don't load menu styles.

LookAndFeelFactory.installJideExtension(
  LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);

这篇关于JMenuItem显示左边的复选框,如何禁用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 11:50