JSplitPane
The JSplitPane class displays two components next to each other with a user moveable dividing bar between them. Usually, the components on either side of the divider will be panels, each containing one of more other components:
The JSplitPane constructor needs three arguments:
- Whether the split should be horizontal or vertical
- The component that should be placed to the left (or top)
- The component that should be placed to the right (or bottom)
Running the above will look as follows:
Notice the dividing bar in the centre of the frame. At the moment it will not move because each of the two panels on either side are at their minimum dimensions and they have not been made scrollable. Enlarge the frame window by dragging the bottom right corner of the frame so it looks as follows:
Now you will be able to drag the centre dividing bar so that it appears in another location:
You can obtain a vertical split simply by modifying the constructor's first argument value: