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

Divider laid out with incorrect size until user drags divider.

XMLWordPrintable



      Name: dc32491 Date: 07/27/2001


      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;

      /**
      <PRE>
      Code below shows bugs in JSplitPane and friends. ( UI, layout, divider ).


      The symptom is that the divider shows up with default with until the user
      moves the divider.

      A precondition of this bug is that the sum of the components' sizes along the
      primary axis is greater than the size of the ( JSplitPane - Inset ). Assuming
      horizontal orientation we are saying that the precondition is
      left width + divider width + right width > split pane width.

      In my opinion, the bug is basically the outcome of the divider's size being
      maintained by each of the four collaborators JSplitPane, BasicSplitPaneDivider,
      BasicSplitPaneUI, and the LayoutManager. We have JSplitPane.dividerSize,
      BasicSplitPaneUI.dividerSize, BasicSplitPaneDivider.dividerSize, and
      BasicHorizontalLayoutManager.sizes. If any of these get out of synch then
      we have a problem.

      In the case of this bug the layoutmanager's size is out of synch.


      </PRE>
      */
      public class test extends javax.swing.JFrame
      {
          class WA extends WindowAdapter
          {
              public void windowClosing( WindowEvent e)
              {
                  System.exit( 0 );
              }
          }

          public test()
          {
              WindowAdapter wa = new WA();
              addWindowListener( wa );

              javax.swing.JLabel l1 = new javax.swing.JLabel( "left1" );
              l1.setPreferredSize( new java.awt.Dimension( 2000, 2000 ) );
              javax.swing.JLabel r1 = new javax.swing.JLabel( "right1" );
              javax.swing.JSplitPane jsp
                  = new javax.swing.JSplitPane( javax.swing.JSplitPane.HORIZONTAL_SPLIT,
                                                        l1, r1 );
              jsp.setDividerSize( 50 );
                                                 
              java.awt.Container cp = getContentPane();
              cp.add( jsp );
          }
          
          public static void main( String[] args )
          throws ClassNotFoundException, InstantiationException,
          IllegalAccessException, javax.swing.UnsupportedLookAndFeelException
          {
              String uiname = javax.swing.UIManager.getSystemLookAndFeelClassName();
              test tt = new test();
              tt.pack();
              tt.show();
          }
      }
      (Review ID: 125764)
      ======================================================================

            apikalev Andrey Pikalev
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: