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

BoxLayout doesn't allocates space properly to JScrollPanes.

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description

      When 2 JScrollPanes are in a container(with BoxLayout), allocating space is wiered. The first ScrollPane gets bigger whenever it needs repainting as a result of:
      1) resize of main frame.
      2) get focus again.

      To reproduce this bug, run the following test app.
      Test Procedure:
      1. try resize main frame( make it bigger or smaller )
      2. click second tab and first tab. repeat it.

      // Test App
      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      public class Test extends JFrame {
          JScrollPane sp1, sp2;
          JPanel onePanel;
          JPanel otherPanel;
          JTabbedPane tp;

          public Test() {
              super("test");
              addWindowListener(wl);

              TreeNode root1 = new TreeNode("test1");
              JTree tree1 = new JTree(root1);

              TreeNode root2 = new TreeNode("test2");
              JTree tree2 = new JTree(root2);

              onePanel = new JPanel();
              onePanel.setLayout(new BoxLayout(onePanel, BoxLayout.X_AXIS));

              sp1 = new JScrollPane();
      sp2 = new JScrollPane();
              sp1.getViewport().add(tree1);
              sp2.getViewport().add(tree2);

              onePanel.add(sp1);
              onePanel.add(sp2);

              otherPanel = new JPanel();
              
              tp = new JTabbedPane();
              tp.addTab("test-tab1", null, onePanel);
              tp.addTab("test-tab2", null, otherPanel);

              tp.setSelectedIndex(0);

              add("Center",tp);

              setSize(500,400);
              show();
          }


          WindowListener wl = new WindowAdapter(){
              public void windowClosing(WindowEvent event){
                  System.exit(0);
              }
          };

          public static void main(String args[]) {
              Test frame = new Test();
          }
      }
      // end of app
       
      bae-chul.kim@Eng 1997-06-26

        Attachments

          Activity

            People

            Assignee:
            sswingtrsunw Swingtraq Swingtraq (Inactive)
            Reporter:
            bkimsunw Bae-chul Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: