MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.BorderLayout;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;

public class MainClass {

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

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