JDK-5006095 : Need a way to programmatically stick JSplitPane divider under j2sdk 1.5
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-03-02
  • Updated: 2017-05-23
Description
Name: rmT116609			Date: 03/01/2004


A DESCRIPTION OF THE REQUEST :
Under previous versions of Java, if JSplitPane.setDividerLocation()
moved the divider all the way to one side or another, it would
"stick" there as the window was resized. Would like this to happen
under 1.5. Even better would be to have a method of JSplitPane or
SplitPaneUI that sticks the divider on request.



JUSTIFICATION :
Under previous Java versions, you could programmatically move a
JSplitPane divider all the way to one side or the other, and it would
"stick" there as the pane was resized. Under 1.5, the divider will not
stick. This makes the interface behavior look sloppy.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Some way to programmatically stick JSplitPane divider.
ACTUAL -
No way to do this.

---------- BEGIN SOURCE ----------

   // Under j2sdk 1.4, the divider will "stick" to the top;
   // under 1.5 it will not.

   import javax.swing.*;

    public class JSplitPaneIssue {
   
       public static void main(String args[]) {
         JFrame frame = new JFrame();
         JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
         split.setResizeWeight(.5);
         split.setTopComponent(new JLabel("top"));
         split.setBottomComponent(new JLabel("bottom"));
         frame.getContentPane().add(split);
         frame.setSize(400, 400);
         frame.setVisible(true);
         
         split.setDividerLocation(0);
         
         // Uncomment the rest to make it work under 1.5.
         /*Object ui = split.getUI();
         if(ui instanceof javax.swing.plaf.basic.BasicSplitPaneUI)
            try {
               java.lang.reflect.Method set_keep_hidden =
                  javax.swing.plaf.basic.BasicSplitPaneUI.class.getDeclaredMethod(
                  "setKeepHidden", new Class[] { boolean.class });
               set_keep_hidden.setAccessible(true);
               set_keep_hidden.invoke(ui, new Object[] { new Boolean(true) }); }
                catch(Exception e) { }*/
      }
   
   }


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use reflection to call BasicSplitPaneUI.setKeepHidden()
(Incident Review ID: 240114) 
======================================================================

Comments
EVALUATION Name: apR10133 Date: 03/05/2004 This is a reasonable request. We need to implement it. ###@###.### ======================================================================
25-09-2004