com.alee.managers.focus
Class DefaultFocusTracker

java.lang.Object
  extended by com.alee.managers.focus.DefaultFocusTracker
All Implemented Interfaces:
FocusTracker

public abstract class DefaultFocusTracker
extends java.lang.Object
implements FocusTracker

Small extension class for FocusTracker that simplifies its creation.

Author:
Mikle Garin

Constructor Summary
DefaultFocusTracker()
          Constructs new tracker with the specified tracked component.
DefaultFocusTracker(boolean uniteWithChilds)
          Constructs new tracker with the specified tracked component.
 
Method Summary
 void addCustomChild(java.awt.Component customChild)
          Adds new custom child.
 java.util.List<java.awt.Component> getCustomChildren()
          Returns custom childs which should be tracked together with this component.
 java.util.List<java.lang.ref.WeakReference<java.awt.Component>> getWeakCustomChildren()
          Returns weakly-referenced custom children.
 boolean isInvolved(java.awt.Component component, java.awt.Component tracked)
          Returns whether specified component is involved with this tracker or not.
 boolean isTrackingEnabled()
          Returns whether tracking is currently enabled or not.
 boolean isUniteWithChilds()
          Returns whether component and its childs in components tree should be counted as a single component or not.
 void removeCustomChild(java.awt.Component customChild)
          Removes custom child.
 void setCustomChildren(java.util.List<java.awt.Component> customChildren)
          Sets custom childs which should be tracked together with this component.
 void setTrackingEnabled(boolean enabled)
          Sets whether tracking is currently enabled or not.
 void setUniteWithChilds(boolean uniteWithChilds)
          Sets whether component and its childs in components tree should be counted as a single component or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.managers.focus.FocusTracker
focusChanged
 

Constructor Detail

DefaultFocusTracker

public DefaultFocusTracker()
Constructs new tracker with the specified tracked component.


DefaultFocusTracker

public DefaultFocusTracker(boolean uniteWithChilds)
Constructs new tracker with the specified tracked component.

Parameters:
uniteWithChilds - whether component and its childs in components tree should be counted as a single component or not
Method Detail

isTrackingEnabled

public boolean isTrackingEnabled()
Returns whether tracking is currently enabled or not.

Specified by:
isTrackingEnabled in interface FocusTracker
Returns:
true if tracking is currently enabled, false otherwise

setTrackingEnabled

public void setTrackingEnabled(boolean enabled)
Sets whether tracking is currently enabled or not.

Parameters:
enabled - whether tracking is currently enabled or not

isInvolved

public boolean isInvolved(java.awt.Component component,
                          java.awt.Component tracked)
Returns whether specified component is involved with this tracker or not. This basically asks whether this object counts towards this tracker focus changes or not.

Specified by:
isInvolved in interface FocusTracker
Parameters:
component - component to check for involvement
tracked - tracked component
Returns:
true if the specified component is involved with this tracker, false otherwise

isUniteWithChilds

public boolean isUniteWithChilds()
Returns whether component and its childs in components tree should be counted as a single component or not. In case component and its childs are counted as one focus changes within them will be ignored by tracker.

Returns:
true if component and its childs in components tree should be counted as a single component, false otherwise

setUniteWithChilds

public void setUniteWithChilds(boolean uniteWithChilds)
Sets whether component and its childs in components tree should be counted as a single component or not.

Parameters:
uniteWithChilds - whether component and its childs in components tree should be counted as a single component or not

getCustomChildren

public java.util.List<java.awt.Component> getCustomChildren()
Returns custom childs which should be tracked together with this component. Note that `isUniteWithChilds` value will also affect how these childs focus is checked.

Returns:
custom childs which should be tracked together with this component

getWeakCustomChildren

public java.util.List<java.lang.ref.WeakReference<java.awt.Component>> getWeakCustomChildren()
Returns weakly-referenced custom children.

Returns:
weakly-referenced custom children

setCustomChildren

public void setCustomChildren(java.util.List<java.awt.Component> customChildren)
Sets custom childs which should be tracked together with this component.

Parameters:
customChildren - custom childs which should be tracked together with this component

addCustomChild

public void addCustomChild(java.awt.Component customChild)
Adds new custom child.

Parameters:
customChild - custom child to add

removeCustomChild

public void removeCustomChild(java.awt.Component customChild)
Removes custom child.

Parameters:
customChild - custom child to remove