com.alee.managers.focus
Class FocusManager

java.lang.Object
  extended by com.alee.managers.focus.FocusManager

public final class FocusManager
extends java.lang.Object

This manager allows you to track certain component their childs focus state by adding your custom FocusTracker or global focus listeners to track component focus state.

Author:
Mikle Garin

Constructor Summary
FocusManager()
           
 
Method Summary
static void addFocusTracker(java.awt.Component component, FocusTracker focusTracker)
          Registers focus tracker.
static java.awt.Component getFocusOwner()
          Returns currently focused component.
static java.awt.Component getOldFocusOwner()
          Returns previously focused component.
static void initialize()
          Initializes manager if it wasn't already initialized.
static void registerGlobalFocusListener(GlobalFocusListener listener)
          Registers global focus listener.
static void removeFocusTracker(FocusTracker focusTracker)
          Unregisters specified focus tracker.
static void removeFocusTrackers(java.awt.Component component)
          Unregisters all focus trackers from the specified component.
static void unregisterGlobalFocusListener(GlobalFocusListener listener)
          Unregisters global focus listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FocusManager

public FocusManager()
Method Detail

initialize

public static void initialize()
Initializes manager if it wasn't already initialized.


getFocusOwner

public static java.awt.Component getFocusOwner()
Returns currently focused component.

Returns:
currently focused component

getOldFocusOwner

public static java.awt.Component getOldFocusOwner()
Returns previously focused component.

Returns:
previously focused component

registerGlobalFocusListener

public static void registerGlobalFocusListener(GlobalFocusListener listener)
Registers global focus listener.

Parameters:
listener - new global focus listener

unregisterGlobalFocusListener

public static void unregisterGlobalFocusListener(GlobalFocusListener listener)
Unregisters global focus listener.

Parameters:
listener - global focus listener to unregister

addFocusTracker

public static void addFocusTracker(java.awt.Component component,
                                   FocusTracker focusTracker)
Registers focus tracker.

Be aware that when all links to either component or focus tracker (outside of the FocusManager) are lost all component focus trackers or specific focus tracker will be disposed. So make sure you keep strong references to whatever you pass here.

Parameters:
focusTracker - new focus tracker

removeFocusTracker

public static void removeFocusTracker(FocusTracker focusTracker)
Unregisters specified focus tracker.

Parameters:
focusTracker - focus tracker to unregister

removeFocusTrackers

public static void removeFocusTrackers(java.awt.Component component)
Unregisters all focus trackers from the specified component.

Parameters:
component - component to unregister all focus trackers from