Java JTree setTreeEnabled(Container container, boolean enabled)

Here you can find the source of setTreeEnabled(Container container, boolean enabled)

Description

set Tree Enabled

License

Open Source License

Declaration

public static void setTreeEnabled(Container container, boolean enabled) 

Method Source Code


//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);
    }
}

Related

  1. scrollToSelection(JTree tree)
  2. scrollTreeToSelectedRow(final JTree tree)
  3. setComponentTreeEnabled(Component c, boolean enabled)
  4. setLeftChildIndent(JTree tree, int indent)
  5. setToolTipOnTree(Container c, String tooltip)
  6. treeListen(final ActionListener listener)
  7. upMove(JTree tree)