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, boolean newContinuousLayout, Component newLeftComponent,
        Component newRightComponent) 

Source Link

Document

Creates a new JSplitPane with the specified orientation and redrawing style, and with the specified components.

Usage

From source file:Main.java

public static void main(String[] a) {
    int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;
    int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;
    boolean continuousLayout = true;
    JLabel label1 = new JLabel("a");
    JLabel label2 = new JLabel("b");
    JLabel label3 = new JLabel("c");
    JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerSize(2);//from   ww  w  .  jav a  2 s  .c  o m
    splitPane1.setDividerLocation(0.5);

    JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3);
    splitPane2.setOneTouchExpandable(true);
    splitPane2.setDividerLocation(0.4);
    splitPane2.setDividerSize(2);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(splitPane2);
    frame.pack();
    frame.setVisible(true);
}

From source file:NestedJSplitPane.java

public static void main(String[] a) {
    int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;

    int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;

    boolean continuousLayout = true;

    JLabel label1 = new JLabel("a");
    JLabel label2 = new JLabel("b");
    JLabel label3 = new JLabel("c");
    JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerSize(2);//from ww  w .  j  av a2  s  . c om
    splitPane1.setDividerLocation(0.5);

    JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3);
    splitPane2.setOneTouchExpandable(true);
    splitPane2.setDividerLocation(0.4);
    splitPane2.setDividerSize(2);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(splitPane2);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();

    ComponentListener comp = new ComponentListener() {
        public void componentHidden(ComponentEvent e) {
            dump("Hidden", e);
        }/*from w  ww  . jav a 2  s  .c  o  m*/

        public void componentMoved(ComponentEvent e) {
            dump("Moved", e);
        }

        public void componentResized(ComponentEvent e) {
            dump("Resized", e);
        }

        public void componentShown(ComponentEvent e) {
            dump("Shown", e);
        }

        private void dump(String type, ComponentEvent e) {
            System.out.println(e.getComponent().getName() + " : " + type);
        }
    };

    JButton left = new JButton("Left");
    left.setName("Left");
    left.addComponentListener(comp);

    final JButton right = new JButton("Right");
    right.setName("Right");
    right.addComponentListener(comp);

    ActionListener action = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            right.setVisible(!right.isVisible());
        }
    };
    left.addActionListener(action);

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right);

    contentPane.add(pane, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.show();
}

From source file:FileTreeFrame.java

public FileTreeFrame(String directory) {
    super("JTree FileSystem Viewer");
    fileDetailsTextArea.setEditable(false);
    fileSystemModel = new FileSystemModel(new File(directory));
    fileTree = new JTree(fileSystemModel);
    fileTree.setEditable(true);//from w  w w. ja v  a2 s. c o m
    fileTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent event) {
            File file = (File) fileTree.getLastSelectedPathComponent();
            fileDetailsTextArea.setText(getFileDetails(file));
        }
    });
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(fileTree),
            new JScrollPane(fileDetailsTextArea));
    getContentPane().add(splitPane);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(640, 480);
    setVisible(true);
}