Example usage for javax.swing JTree JTree

List of usage examples for javax.swing JTree JTree

Introduction

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

Prototype

public JTree() 

Source Link

Document

Returns a JTree with a sample model.

Usage

From source file:Main.java

public static void main(String[] argv) {
    JTree tree = new JTree() {
        protected void setExpandedState(TreePath path, boolean state) {
            if (state) {
                super.setExpandedState(path, state);
            }/*from  w  w  w.j  a v  a 2 s.  c  o m*/
        }
    };
}

From source file:Main.java

public static void main(String[] args) {
    JTree tree = new JTree();
    tree.setVisibleRowCount(10);//w w w. j av  a  2s.c om
    JOptionPane.showMessageDialog(null, new JScrollPane(tree));
}

From source file:TreeRowHeight15.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(15);//  ww  w  .  j av a 2 s .c  om

    JFrame frame = new JFrame("Image");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:TreeRowHeightCache.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    if (tree.getRowHeight() <= 0) {
        tree.setRowHeight(1);/*from   ww  w  .j  ava2 s.c o m*/
    }
    tree.setRowHeight(0);

    JFrame frame = new JFrame("Image");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:TreeRowHeightCalculation.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(0);//from   www . ja v a2s . c  om

    JFrame frame = new JFrame("tree row height calculation");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTree tree = new JTree();
    visitAllNodes(tree);
}

From source file:Main.java

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

    JTree tree = new JTree();

    int startRow = tree.getRowCount() - 1;
    String prefix = "b";
    TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Backward);
    System.out.println(path);//w w  w. j  a v a  2 s. c  om

}

From source file:Main.java

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

    JTree tree = new JTree();

    // Search forward from first visible row looking for any visible node
    // whose name starts with prefix.
    int startRow = 0;
    String prefix = "b";
    TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Forward);
    System.out.println(path);// www. j  a  v  a2  s . c o m
}

From source file:Main.java

public static void main(String[] args) {
    JTree tree = new JTree();
    InputMap inputMap = tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke[] keyStrokes = inputMap.allKeys();
    for (KeyStroke keyStroke : keyStrokes) {
        Object actionCommand = inputMap.get(keyStroke);
        System.out.println("keyStroke = " + keyStroke);
        System.out.println("actionCommand = " + actionCommand);
    }/*from   w  w  w  .  j  a  va2 s .c  o  m*/
}

From source file:Main.java

public static void main(String[] argv) {

    JTree tree = new JTree() {
        protected void setExpandedState(TreePath path, boolean state) {

            if (state) {
                super.setExpandedState(path, state);
            }/*  w ww  .ja  va2  s  .c o  m*/
        }
    };

    JFrame frame = new JFrame("Ignore all collapse requests");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}