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

JSplitPane option to not resize/adjust divider location on component add/remove

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      Additional JSplitPane functionallity should configurably,

      (a) * Not adjust or change its size or divider location when a component is added to the left or right of the splitpane.

      (b) * Only adjust or change its size or divider location when the added components preferred size is larger than the visible split area for that component. BorderLayout.CENTER should be ignored w.r.t the calculation regarding whether the splitpane should be resized and the divider moved.


      JUSTIFICATION :
      In an index use-case of a JSplitPane, there is typically an index (JList, JTree, etc) on the left and a detail view on the right. Clicking on a component on the left would change the view on the right.

      The adjustment by the user is typically to visually optimise the display of the index while keeping as much space as reasonable to view the detail part of the splitpane. Any re-adjustment of the index part of the splitpane is unnecessary and visually irritating.

      What is important is visual stability of the index. A change of the detail panel should not affect the view of the index as this is visually optimised by the user.

      While there are many different use-cases, I would claim that they their interactions are either improved or unaffected by this RFE.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When the setResizePolicy(RESIZE_STICKY) option of the JSplitPane is set and a component is added or removed (setLeftComponent, setRightComponent) the divider location MUST NOT change even if there is a better layout for the user. If a component is removed, (or for example setLeftComponent(null)) the divider location MUST NOT change.

      ACTUAL -
      There is currently no resize policy that prevents resize adjustment when a component is removed. You can set various policies on what should happen when the scroll area is increased (window size increase etc).

      This is very disturbing when the right component is removed (null selection in the index) and the index is then resize automatically.

      Extremely visually disturbing.

      CUSTOMER SUBMITTED WORKAROUND :


      final JSplitPane sp = ...
      final int size = sp.getDividerLocation();

      /// perform adjustment
      sp.setRightComponent(null);

      SwingUtilities.invokeLater( new Runnable()
      {
       public static void run()
      {
        sp.setDividerLocation(size);
      }
      }
      );
      ###@###.### 2005-2-26 00:13:44 GMT

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: