简体   繁体   English

我在 jpanel 上替换 jmenubar 时遇到问题

[英]I got problem with replacing jmenubar on jpanel

I am writing a desktop application using java swing with netbeans gui manager.我正在使用 java swing 和 netbeans gui 管理器编写桌面应用程序。 I want replace vertical menu with submenus on Jpanel but when I am putting Jmenubar on Jpanel it does not work.我想用 Jpanel 上的子菜单替换垂直菜单,但是当我将 Jmenubar 放在 Jpanel 上时它不起作用。 I need some help with this.我需要一些帮助。

A JMenubBar is designed to be added to the JFrame using the setJMenuBar(...) method. JMenubBar旨在使用setJMenuBar(...)方法添加到JFrame中。

If you want to use popup menus for other Swing components then you should be using a JPopupMenu .如果您想为其他 Swing 组件使用弹出菜单,那么您应该使用JPopupMenu

Read the section from the Swing tutorial on How to Use Menus for more information and working examples to get you started.阅读 Swing 教程中有关如何使用菜单的部分,以获取更多信息和工作示例以帮助您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM