我制作了一个桌面应用程序。我使用 Netbeans 7 IDE 制作的。
在其中,我创建了一个名为 look and feel 的菜单。我通过从调色板中拖动菜单来创建它。菜单项是 Window、Metal 和 Motif。我希望在菜单项选择时改变外观。菜单项是复选框菜单项。我右键单击菜单项并在 netbeans 中选择事件并添加了一些代码。但是当我在运行项目后选择菜单项时,没有任何反应并且 GUI 被卡住。
请提出解决方案。
最佳答案
我建议您改为使用单选按钮。现在解决您的问题,
..and added a few codes.
我不确定这些代码是什么,但我猜这可能丢失了,
To make existing components reflect the new L&F, invoke the SwingUtilities updateComponentTreeUI method once per top-level container.
所以在这之后,
UIManager.setLookAndFeel(lnfName);
你也需要这些,
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();
关于java - 将 Action 事件添加到外观菜单项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8381425/