简体   繁体   中英

How do I add a menubar to a tabbed pane?

Is it possible to add a menubar to one of the windows in a tabbed pane? And is a frame the only container which can have a menubar?

As Suraj mentioned, you can force the issue as as they are both, both components and containers however you will have to do the extra work to organize it in your pane's layout along with the rest of the components in the pane -- unlike with a JFrame which has methods to support it outright (setJMenuBar and you're outta there). Normally, when added to a JFrame, the JMenuBar is not in the content pane, it is in a layered pane which contains both the menu bar and the content pane below it.

You might also want to consider using a JToolBar which is very flexible (more easily customized) and has some optional built-in goodies like being separable/dockable.

Though you can directly add a JMenubar in to a JtabbedPane as both are JComponents. But it wont look nice(usable), if you have tried it.

I would suggest to subclass BasicTabbedPaneUI and override installComponents(), there you can add you JmenuBar at the top or wherever you want.

Is it possible to add a menubar to one of the windows in a tabbed pane?

What problem did you have when you tried to do this?

If you need more help post your SSCCE showing the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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