Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8265586

[windows] last button is not shown in AWT Frame with BorderLayout and MenuBar set.

XMLWordPrintable

    • b02
    • windows_10

        Please see sample below, issue can be workarounded by calling pack() twice or by resizing window.

        import java.awt.BorderLayout;
        import java.awt.Button;
        import java.awt.Frame;
        import java.awt.HeadlessException;
        import java.awt.Menu;
        import java.awt.MenuBar;
        import java.awt.Panel;

        public class WindowsBorderLayoutMenuPack extends Frame {

            public WindowsBorderLayoutMenuPack() throws HeadlessException {
                setLayout(new BorderLayout());

                MenuBar mb = new MenuBar();
                Menu m = new Menu("Menu");
                mb.add(m);

                setMenuBar(mb);

                Panel panel = new Panel();
                panel.add(new Button("Dummy Button B1"));
                panel.add(new Button("Dummy Button B2"));

                add(panel, BorderLayout.CENTER);
            }

            public static void main(String[] args) {
                WindowsBorderLayoutMenuPack frame = new WindowsBorderLayoutMenuPack();
                frame.setLocationRelativeTo(null);
                frame.pack();
                //frame.pack(); // uncomment to workaround the issue, only works if pack() called twice.
                frame.setVisible(true);
            }
        }

              honkar Harshitha Onkar
              azvegint Alexander Zvegintsev
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: