Reputation: 1
I want to have my menubar and help bar appear next to each other but if they both share the same position they overlap, how do i get them to sit next to each other?
add(menuBar, BorderLayout.PAGE_START);
add(helpBar, BorderLayout.PAGE_START);
Upvotes: -2
Views: 36
Reputation: 324207
The standard UI for a frame it to have a:
displayed vertically.
So the standard code would be:
frame.setJMenuBar( menuBar );
frame.add(toolBar, BorderLayout.Page_START);
If you really want the menuBar and toolBar to display on the same line then you would need to add the toolBar to the menuBar.
The code might be something like:
menuBar.add( Box.createHorizontalGlue() );
menuBar.add( toolBar );
Now the toolBar will appear on the right side of the frame.
If you want the toolBar right beside the menuBar then try:
menuBar.add( Box.createHorizontalStrut(10) );
menuBar.add( toolBar );
Upvotes: 0