简体   繁体   English

如何在我的JMenuBar上添加JButton?

[英]How to add a JButton on my JMenuBar?

For a assignment I am to modify an existing java applet. 对于作业,我将修改现有的Java applet。 I'm trying to get a JButton (or a clickable JMenu) on my JMenuBar. 我正在尝试在我的JMenuBar上获取一个JButton(或可单击的JMenu)。 There are a few menu's and one of them should be usable as a button. 有几个菜单,其中一个应该可以用作按钮。

I found the same question several times but the winning answer stated that it would be "bad" and should still be an item in a JMenu. 我几次发现相同的问题,但胜出的答案表明这将是“错误的”,并且仍应是JMenu中的一项。 While this is a possibility I really would prefer otherwise. 虽然这是一种可能性,但我确实更愿意。

Thank you. 谢谢。

I found this post that (I think) is related to your question: 我发现这篇文章(我认为)与您的问题有关:

How to make a JMenu have Button behaviour in a JMenuBar 如何使JMenu在JMenuBar中具有Button行为

Is this wat you are trying to accomplish? 这是您要完成的任务吗?

Good luck! 祝好运!

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

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