Here you can find the source of setTreeEnabled(Container container, boolean enabled)
public static void setTreeEnabled(Container container, boolean enabled)
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { public static void setTreeEnabled(Container container, boolean enabled) { synchronized (container.getTreeLock()) { for (Component comp : container.getComponents()) { setComponentEnabled(comp, enabled); }/*from ww w.ja va 2s. co m*/ } } public static void setComponentEnabled(Component comp, boolean enabled) { if (comp instanceof JScrollPane) { Component c = ((JScrollPane) comp).getViewport().getView(); if (c instanceof Container) setTreeEnabled((Container) c, enabled); } else if (comp instanceof Container) { setTreeEnabled((Container) comp, enabled); } else { comp.setEnabled(enabled); } comp.setEnabled(enabled); } }