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

Bad window size calculation after using pack()

    XMLWordPrintable

Details

    • b48
    • x86
    • linux
    • Not verified

    Backports

      Description

        FULL PRODUCT VERSION :
        openjdk version "1.6.0-internal"
        OpenJDK Runtime Environment (build 1.6.0-internal-langel_02_jun_2008_10_58-b00)
        OpenJDK Server VM (build 10.0-b19, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux towel.yyz.redhat.com 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :

        The pack() method of the Window class allow to resize the window based on the
        contents preferred sizes, when using OpenJDK on the following example, the
        window always have a empty area below (that does not happens of the Sun Java
        binaries)

        import java.awt.FlowLayout;

        import javax.swing.JButton;
        import javax.swing.JFrame;
        import javax.swing.JPanel;
        import javax.swing.WindowConstants;

        public class TestFrame {
            public static void main(String[] args) {
                JFrame frame = new JFrame();
                JPanel panel = new JPanel(new FlowLayout());
                panel.add(new JButton("Testing..."));
                frame.setContentPane(panel);
                
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
            }
        }



        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        run the test case

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Window should be framed around the center button
        ACTUAL -
        Window is longer than it should be. size calculated wrong

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.FlowLayout;

        import javax.swing.JButton;
        import javax.swing.JFrame;
        import javax.swing.JPanel;
        import javax.swing.WindowConstants;

        public class TestFrame {
            public static void main(String[] args) {
                JFrame frame = new JFrame();
                JPanel panel = new JPanel(new FlowLayout());
                panel.add(new JButton("Testing..."));
                frame.setContentPane(panel);
                
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
            }
        }
        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

                art Artem Ananiev (Inactive)
                ndcosta Nelson Dcosta (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: