Java examples for Swing:JTree
get Component Tree Count
//package com.java2s; import java.awt.*; public class Main { public static int getComponentTreeCount(Container c) { int cn = 1; for (Component node : c.getComponents()) { if (node instanceof Container) { cn += getComponentTreeCount((Container) node); } else { cn++;//from w w w . ja v a2 s . co m } } return cn; } }