com.alee.utils.swing
Class AutoExpandSingleChildNodeListener

java.lang.Object
  extended by com.alee.utils.swing.AutoExpandSingleChildNodeListener
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.TreeExpansionListener

public class AutoExpandSingleChildNodeListener
extends java.lang.Object
implements javax.swing.event.TreeExpansionListener

Tree expansion listener that automatically expands node futher if it has only one child. Actual expand operation occurs right after node expand event and works only on its childs. Be aware that this listener is not suited for async trees.

Author:
Mikle Garin

Constructor Summary
AutoExpandSingleChildNodeListener()
           
 
Method Summary
static AutoExpandSingleChildNodeListener install(javax.swing.JTree tree)
          Installs listener into tree and ensures that it is the only one installed.
static boolean isInstalled(javax.swing.JTree tree)
          Returns whether the specified tree has any listeners installed or not.
 void treeCollapsed(javax.swing.event.TreeExpansionEvent event)
          
 void treeExpanded(javax.swing.event.TreeExpansionEvent event)
          
static void uninstall(javax.swing.JTree tree)
          Uninstalls all listeners from the specified tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoExpandSingleChildNodeListener

public AutoExpandSingleChildNodeListener()
Method Detail

treeExpanded

public void treeExpanded(javax.swing.event.TreeExpansionEvent event)

Specified by:
treeExpanded in interface javax.swing.event.TreeExpansionListener

treeCollapsed

public void treeCollapsed(javax.swing.event.TreeExpansionEvent event)

Specified by:
treeCollapsed in interface javax.swing.event.TreeExpansionListener

install

public static AutoExpandSingleChildNodeListener install(javax.swing.JTree tree)
Installs listener into tree and ensures that it is the only one installed.

Parameters:
tree - tree to modify
Returns:
installed listener

uninstall

public static void uninstall(javax.swing.JTree tree)
Uninstalls all listeners from the specified tree.

Parameters:
tree - tree to modify

isInstalled

public static boolean isInstalled(javax.swing.JTree tree)
Returns whether the specified tree has any listeners installed or not.

Parameters:
tree - tree to process
Returns:
true if the specified tree has any listeners installed, false otherwise