Example usage for javax.swing Box add

List of usage examples for javax.swing Box add

Introduction

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

Prototype

public Component add(String name, Component comp) 

Source Link

Document

Adds the specified component to this container.

Usage

From source file:MainClass.java

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

    Box box = Box.createHorizontalBox();

    JTree tree1 = new JTree();
    JScrollPane scrollPane1 = new JScrollPane(tree1);
    tree1.setAutoscrolls(true);/*from   w  w  w  . j  av a2 s  .c o m*/

    JTree tree2 = new JTree();
    tree2.putClientProperty("JTree.lineStyle", "None");
    JScrollPane scrollPane2 = new JScrollPane(tree2);

    box.add(scrollPane1, BorderLayout.WEST);
    box.add(scrollPane2, BorderLayout.EAST);

    frame.add(box, BorderLayout.CENTER);
    frame.setSize(300, 240);
    frame.setVisible(true);
}

From source file:TreeLines.java

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

    Container content = frame.getContentPane();
    Box box = Box.createHorizontalBox();

    JTree tree1 = new JTree();
    tree1.putClientProperty("JTree.lineStyle", "Angled");
    JScrollPane scrollPane1 = new JScrollPane(tree1);
    tree1.setAutoscrolls(true);/* w w  w.  ja v  a2s  .  co  m*/

    JTree tree2 = new JTree();
    JScrollPane scrollPane2 = new JScrollPane(tree2);

    box.add(scrollPane1, BorderLayout.WEST);
    box.add(scrollPane2, BorderLayout.EAST);

    frame.getContentPane().add(box, BorderLayout.CENTER);
    frame.setSize(300, 240);
    frame.setVisible(true);
}