bibliothek.gui.dock.control.focus
Class DefaultFocusStrategy

java.lang.Object
  extended by bibliothek.gui.dock.control.focus.DefaultFocusStrategy
All Implemented Interfaces:
FocusStrategy

public class DefaultFocusStrategy
extends Object
implements FocusStrategy

The DefaultFocusStrategy keeps track of the last focused Component of any Dockable that is registered at a DockController.

Author:
Benjamin Sigg

Constructor Summary
DefaultFocusStrategy(DockController controller)
           
 
Method Summary
 void bind()
          Informs this strategy that it will be used from now on.
protected  boolean excluded(Component component, FocusStrategyRequest request)
          Tells whether the focusable Component component should be treated like a non-focusable Component.
protected  boolean focusable(Component component, FocusStrategyRequest request)
          Tells whether the non-focusable component in reality is focusable.
 Component getFocusComponent(FocusStrategyRequest request)
          Given a Dockable this method tells which Component should be focused.
 boolean shouldFocusAfterDrop(Dockable dockable)
          Called after dockable was dropped on a new parent due to a relocation operation (an operation that was visible to the user or that was performed by the user).
 void unbind()
          Informs this strategy that it is no longer used from now on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFocusStrategy

public DefaultFocusStrategy(DockController controller)
Method Detail

shouldFocusAfterDrop

public boolean shouldFocusAfterDrop(Dockable dockable)
Description copied from interface: FocusStrategy
Called after dockable was dropped on a new parent due to a relocation operation (an operation that was visible to the user or that was performed by the user).

Specified by:
shouldFocusAfterDrop in interface FocusStrategy
Parameters:
dockable - the element that changed its position
Returns:
true if focus should be (again) transfered to dockable, false if the focus should remain where it is (this may mean, that dockable loses the focus)

focusable

protected boolean focusable(Component component,
                            FocusStrategyRequest request)
Tells whether the non-focusable component in reality is focusable. This is true for example for any child of a JComboBox.

Parameters:
component - the component which seems to be not focusable, but in reality is focusable
request - information about the item that gains the focus
Returns:
true if component should be treated as if it would be focusable

excluded

protected boolean excluded(Component component,
                           FocusStrategyRequest request)
Tells whether the focusable Component component should be treated like a non-focusable Component.

Parameters:
component - some focusable component which may get the focus
request - information about the item that gains the focus
Returns:
true if component should be treated as if it were not focusable

getFocusComponent

public Component getFocusComponent(FocusStrategyRequest request)
Description copied from interface: FocusStrategy
Given a Dockable this method tells which Component should be focused.

Specified by:
getFocusComponent in interface FocusStrategy
Parameters:
request - information about the Dockable that is about to be focused. Also offers verification that a Component is a valid target. All the information from request are suggestions, in the end only the result of this method will count.
Returns:
the component to focus or null.
  • null indicates that this strategy cannot decide what to do. In this case a default component will receive the focus.
  • mouseClicked forces focus onto mouseClicked, even if that Component is not focusable.
  • any other Component will receive focus if focusable, or focus will be transfered to the next focusable Component starting the search at the returned value.

bind

public void bind()
Description copied from interface: FocusStrategy
Informs this strategy that it will be used from now on.

Specified by:
bind in interface FocusStrategy

unbind

public void unbind()
Description copied from interface: FocusStrategy
Informs this strategy that it is no longer used from now on.

Specified by:
unbind in interface FocusStrategy