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

On GridLayout and other layouts sometimes do not align its first child exactly at the top left corner

XMLWordPrintable

      We do the following on Linux Ubuntu 12.04

      1) Create a JFrame and add a JButton to its content pane
      2) Show the JFrame and log the screen coordinates of the JButton
      3) Remove the button from the JFrame
      4) Set a new GridLayout to the JFrame
      5) Add the same button to the GridLayout
      6) Display the JFrame and log the button coordinates again

      We can see that sometimes the JButton coordinates differ by one pixel when the button belongs to the GridLayout.

      For example, with the frame size (100, 200) and the GridLayout(3, 6) we can see that the button gets placed at (66, 52) with the default layout but at (66, 53) with the GridLayout.

      As this JButton is the only child within the GridLayout and the grid's hGap and vGap are both set to 0 we believe there shall be no such extra pixel.

      We can observe the same with other layout types, too.

      On Windows the issue can not be observed.

      We have a functional test failing on Linux because of this issue.
      AWT_LayoutTest/Automated/GridLayout/ChangeGrids

        1. GridTest.java
          1 kB
          Alexander Kulyakhtin

            Unassigned Unassigned
            akulyakh Alexander Kulyakhtin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: