JSplitPane and its components

The class javax.swing.JSplitPane allows you to have two components with a split bar between them. At runtime you can select the split bar and move it, thereby saving space on the screen. The two child components are shown beneath the JSplitPane on the Java Beans view. When you drop a new component on the Java Beans view or the Design view, it will become the left component if there is no existing child. Otherwise, it becomes the right component. If there is already a left and right component, then a drop is not allowed.

Whether the Visual Editor for Java shows the left and right component as children depends on the value of its orientation property. If this property is set to VERTICAL_SPLIT then the bottom and top component are shown instead.

The method generated for each of the split pane children is to set one of its properties using a set method. For example:

ivjJSplitPane.setTopComponent(getIvjJButton());

In addition to setting a component using a set method, it can be added using a constraint of "top", "bottom" "left" or "right". For example:

ivjJSplitPane.addComponent(getIvjJButton(),"top");

The style with the set method is the one that is generated, although if the code uses the add(Component,Object) method with a valid constraint, it will be recognized by the Visual Editor for Java.

When dropping components onto a JSplitPane, if the divider location is not explicitly set it will change according to the preferred size of the left or top component. Then it will fill the opposite side with the remaining component if one is set. For example, if you drop a JPanel into a JSplitPane with no components, it will be assigned by default to the left side. The divider location will move to the far left in the split pane because the preferredSize for a JPanel is very small. If you then drop components onto the JPanel that has a FlowLayout, the split pane will resize according to the preferred size of the JPanel, which has now changed because of the preferred sizes of the components that were added to it.

The Visual Editor for Java will render JLayeredPane indexes in a single layer. In the case of multilayer / indexes, the Visual Editor for Java may not show the components in the correct order.

Related concepts
Containers and layout managers
Swing windows with a content pane
JTabbedPane and its pages
JTable and its columns

(C) Copyright IBM Corporation 2000, 2003. All Rights Reserved.