Setting the Row Height of a JTree Component - Java Swing

Java examples for Swing:JTree

Description

Setting the Row Height of a JTree Component

Demo Code

import javax.swing.JTree;

public class Main {
  public static void main(String[] args) throws Exception {
    JTree tree = new JTree();

    // All rows will be given 15 pixels of height
    tree.setRowHeight(15);//w ww. j a  va2  s.  c o m

    // Have the row height for each row computed individually
    tree.setRowHeight(0);

    if (tree.getRowHeight() <= 0) {
      tree.setRowHeight(1);
    }
    tree.setRowHeight(0);
  }
}

Related Tutorials