Example usage for javax.swing JSplitPane JSplitPane

List of usage examples for javax.swing JSplitPane JSplitPane

Introduction

In this page you can find the example usage for javax.swing JSplitPane JSplitPane.

Prototype

public JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent) 

Source Link

Document

Creates a new JSplitPane with the specified orientation and the specified components.

Usage

From source file:Main.java

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

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);
    int size = pane.getDividerSize();
    size = 1;/*from   ww w  .jav a  2  s  . c  om*/
    pane.setDividerSize(size);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

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

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

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

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

    boolean b = vpane.isOneTouchExpandable(); // false by default

    vpane.setOneTouchExpandable(true);/*from  ww  w  .j av  a2 s.c om*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);
    double weight = pane.getResizeWeight(); // 0.0 by default

    weight = 1D;//  w w w  . j  av  a 2 s.  c  o  m
    pane.setResizeWeight(weight);

    weight = .5D;
    pane.setResizeWeight(weight);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

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

    boolean b = vpane.isContinuousLayout(); // false by default

    // Set the split pane to continuously resize the child components which the divider is dragged
    vpane.setContinuousLayout(true);//w w  w. ja  v a2  s  .  c  o m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

    int loc = pane.getDividerLocation();

    loc = (int) ((pane.getBounds().getWidth() - pane.getDividerSize()) / 2);
    pane.setDividerLocation(loc);/*from w  ww.  j ava2s .  c o m*/

    double propLoc = .5D;
    pane.setDividerLocation(propLoc);
}

From source file:Main.java

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

    // Create a left-right split pane
    JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

}

From source file:Main.java

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);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("SplitPaneFrame");

    JLabel leftImage = new JLabel(new ImageIcon("a.gif"));
    Component left = new JScrollPane(leftImage);
    JLabel rightImage = new JLabel(new ImageIcon("b.gif"));
    Component right = new JScrollPane(rightImage);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
    split.setDividerLocation(100);/*from  w w  w .j ava2 s.  co m*/
    frame.getContentPane().add(split);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Use TextAction");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTextArea leftArea = new JTextArea();
    final JTextArea rightArea = new JTextArea();

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftArea),
            new JScrollPane(rightArea));
    splitPane.setDividerLocation(.5);//w ww .  j a  v  a2  s.  c om

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);
    JMenu menu = new JMenu("Options");
    menuBar.add(menu);
    JMenuItem menuItem;

    Action readAction = leftArea.getActionMap().get(DefaultEditorKit.readOnlyAction);
    menuItem = menu.add(readAction);
    menuItem.setText("Make read-only");
    Action writeAction = leftArea.getActionMap().get(DefaultEditorKit.writableAction);
    menuItem = menu.add(writeAction);
    menuItem.setText("Make writable");
    menu.addSeparator();

    Action cutAction = leftArea.getActionMap().get(DefaultEditorKit.cutAction);
    menuItem = menu.add(cutAction);
    menuItem.setText("Cut");
    Action copyAction = leftArea.getActionMap().get(DefaultEditorKit.copyAction);
    menuItem = menu.add(copyAction);
    menuItem.setText("Copy");
    Action pasteAction = leftArea.getActionMap().get(DefaultEditorKit.pasteAction);
    menuItem = menu.add(pasteAction);
    menuItem.setText("Paste");

    frame.add(splitPane, BorderLayout.CENTER);
    frame.setSize(400, 250);
    frame.setVisible(true);

}