tags:

views:

85

answers:

3

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?

A: 

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.

Suraj Chandran
A: 

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.

camickr
My issue was I thought menubar could only be added outside the content panes and only to components like frames etc that have methods to handle it.
Goutham
@camickr..you seem to be an evangelist of SSCCE :) Are you the same guy who used to answer lot of swing question in the sun forum?
Suraj Chandran
"My issue was I thought" - And that was my point, don't think, try it. How do you ever expect to learn if you don't try things on your own? Your computer will not blow up or anything! It will only take 5 minutes to try it. Then if it doesn't work the way you expect you post your SSCCE so we have an idea what you tried. And yes I'm the guy from the Sun forum who always requests a SSCCE's because its shows you've made an effort.
camickr
+1  A: 

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.

charstar