Here you can find the source of collapseAllRows(JTree tree)
private static void collapseAllRows(JTree tree)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { private static void collapseAllRows(JTree tree) { for (int i = tree.getRowCount() - 1; i >= 0; i--) { tree.collapseRow(i);/*from ww w. ja va 2 s. c o m*/ } } }