Search code examples
javaswinglayoutborderjsplitpane

How to implement JSplitPane in the BorderLayout?


HI,

how can i use the JSplitPane so that they show up in the borders of a BorderLayout???

So that i can resize each sise (NORTH, EAST, WEST, SOUTH, CENTER).

Thanks


Solution

  • Well for that you don't really need BorderLayout. You can add the split panes together for that effect. Because JSplitPane only supports splitting of 2 components, you need 2 JSplitPane vertically, and 2 JSplitPane inside the second vertical JSplitPane.

    JSplitPane horizontal1 = new JSplitPane(
        JSplitPane.HORIZONTAL_SPLIT, yourCenterPanel, yourEastPanel);
    JSplitPane horizontal2 = new JSplitPane(
        JSplitPane.HORIZONTAL_SPLIT, yourWestPanel, horizontal1);
    JSplitPane vertical1 = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT, horizontal2, yourSouthPanel);
    JSplitPane vertical2 = new JSplitPane(
        JSplitPane.VERTICAL_SPLIT, yourNorthPanel, vertical1);
    whateverPlaceYouWant.add(vertical2);