简体   繁体   English

在Java中的awt包中删除MenuBar

[英]Removing MenuBar in awt package in java

Is there any way available to remove the menubar from window in java in awt package. 有什么方法可以从awt包中的java中的窗口中删除菜单栏。 I have created menubar based on a condition and when the condition gets false,i want to remove it in awt package(not using swing class methods), but unable to find any method to do so. 我已经基于条件创建了菜单栏,当条件为假时,我想在awt包中删除它(不使用swing类方法),但是找不到任何方法可以这样做。

I should be able to create/remove menubars more than once based on the condition. 我应该能够根据情况多次创建/删除菜单栏。

I am shocked to fail to find any method to completely remove the menubar even at the documentation provided by Oracle, though methods exists to remove components from menubar. 尽管存在从菜单栏中删除组件的方法,但即使在Oracle提供的文档中,也找不到任何方法来完全删除菜单栏,我感到震惊。

IS it a loophole?Did they missed something? 这是一个漏洞吗?他们错过了什么吗?

Try: setMenuBar(null); 试试: setMenuBar(null);

From the documentation: 从文档中:

mb - the menu bar being set. mb-设置的菜单栏。 If this parameter is null then any existing menu bar on this frame is removed. 如果此参数为null,则将删除此框架上所有现有的菜单栏。

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

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