Getting the Setting the Children in a JSplitPane Container : Splitpane « Swing JFC « Java






Getting the Setting the Children in a JSplitPane Container

  

import javax.swing.JButton;
import javax.swing.JSplitPane;

public class Main {
  public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");

    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

    JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

    JSplitPane vpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComponent, bottomComponent);

    leftComponent = (JButton) hpane.getLeftComponent();
    rightComponent = (JButton) hpane.getRightComponent();

    topComponent = (JButton) vpane.getTopComponent();
    bottomComponent = (JButton) vpane.getBottomComponent();

    hpane.setLeftComponent(topComponent);
    hpane.setRightComponent(bottomComponent);

    vpane.setTopComponent(leftComponent);
    vpane.setBottomComponent(rightComponent);
  }
}

   
    
  








Related examples in the same category

1.Create a left-right split pane
2.Create a top-bottom split pane
3.A quick test of the JSplitPane classA quick test of the JSplitPane class
4.SplitPane Demo 2
5.Swing SplitPane SampleSwing SplitPane Sample
6.Resize SplitPaneResize SplitPane
7.SplitPane: VerticalSplitSplitPane: VerticalSplit
8.SplitPane Sample 3SplitPane Sample 3
9.Property SplitProperty Split
10.Use the split paneUse the split pane
11.Continuously move the divider and resize its child components while the user is dragging the divider
12.Getting and Setting the Divider Location in a JSplitPane Container
13.Distributing Space When a JSplitPane Container Is Resized
14.The split pane supports a one-touch-expandable capability that allows the user to conveniently move the divider to either end with a single click
15.This program demonstrates the split pane component organizer.This program demonstrates the split pane component organizer.