-2

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);

1 Answers1

0

The standard UI for a frame it to have a:

  1. Title bar
  2. Menu bar
  3. Tool bar

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 );
camickr
  • 321,443
  • 19
  • 166
  • 288