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

REGRESSION: JSplitPane.setDividerLocation is no longer respected

XMLWordPrintable

    • b32
    • 6
    • x86
    • windows_2000

      A DESCRIPTION OF THE REGRESSION :
      JSplitPane.setDividerLocation is no longer respected

      We store the users last divider location and then use setDividerLocation to set it back to how it was when they next use the same screen. In earlier JDKs this worked fine, in Mustang all the Split Panes are completely messed up (dividers all in the wrong places).

      As a workaround we can add a component resized listener and the call setDividerLocation to move the divider to it's correct location.

        Suggested for a fix: in javax.swing.plaf.basic.BasicSplitPaneUI where it says:
      if (painted) {
      // This is tricky, there is never a good time for us
      // to push the value to the splitpane, painted appears to
      // the best time to do it. What is really needed is
      // notification that layout has completed.
      use spDividerLocation instead of getDividerLocation(splitPane)
      (for us the spDividerLocation has the correct location).

      Looking at this code it probably all needs to be fixed, hard to work out what this code is even trying to do.

       

      REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
      import static javax.swing.JFrame.*;
      import static javax.swing.JSplitPane.*;
      import javax.swing.*;

      public class Test {
        public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              JFrame frame = new JFrame();
              JSplitPane splitPane = new JSplitPane(HORIZONTAL_SPLIT, new JLabel("One"), new JLabel("Two"));
              splitPane.setDividerLocation(500);
              frame.add(splitPane);
              frame.pack();
              frame.setVisible(true);
              frame.setSize(1000, 1000);
              frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            }
          });
        }
      }


      RELEASE LAST WORKED:
      5.0 Update 6

      RELEASE TEST FAILS:
      mustang-beta

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Divider to appear in the center of the frame (at location 500 set by setDividerLocation).
      ACTUAL -
      The Divider appears almost at the left of the frame (so that the left label has just enough space).
      Note as well as mustang-beta build 73 I also tested our application against mustang build 47 and it was broken even then.

      OBSERVED APPLICATION IMPACT:
      I would expect that many applications that are using setDividerLocation will end of with all their screens messed up (users will have to resize the dividers everytime they use these screens).

            svioletsunw Scott Violet (Inactive)
            avishentsunw Alexey Vishentsev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: