org.zaval.lw
Class LwFocusManager

java.lang.Object
  |
  +--org.zaval.lw.LwFocusManager
All Implemented Interfaces:
java.util.EventListener, LwComponentListener, LwContainerListener, LwKeyListener, LwManager, LwMouseListener

public class LwFocusManager
extends java.lang.Object
implements LwManager, LwMouseListener, LwComponentListener, LwContainerListener, LwKeyListener

This class is an implementation of the LwFocusManager for the libarary. According to the implementation the light weight component can be a focus owner if the component canHaveFocus method returns true and the component is enabled and visible.

The focus manager implements the mouse listener interface to deliver focus to a light weight component. The manager controls (by implementing LwComponentListener, LwContainerListener listeners interfaces) when the focus owner component is disabled, hidden or removed from the parent component to take away the focus if it is necessary.

The manager implements keyboard listener interface to change focus owner when the "TAB" key has been pressed.

The manager provides following methods that are used by other components of the library:


Constructor Summary
LwFocusManager()
           
 
Method Summary
 void compAdded(LwContainerEvent e)
          Invoked when the light weight component has been added to the container.
 void compDisabled(LwComponentEvent e)
          Invoked when the light weight component has been disabled.
 void compEnabled(LwComponentEvent e)
          Invoked when the light weight component has been enabled.
 void compHidden(LwComponentEvent e)
          Invoked when the light weight component has been hidden.
 void compRemoved(LwContainerEvent e)
          Invoked when the light weight component has been removed from the container.
 void compShown(LwComponentEvent e)
          Invoked when the light weight component has been shown.
 void dispose()
           
 LwComponent findFocusable(LwComponent c)
          Looks for a component that can be the focus owner starting from the specified component.
 LwComponent getFocusOwner()
          Gets the focus owner component.
 boolean hasFocus(LwComponent c)
          Tests if the specified component has the focus.
protected  boolean isFocusable(LwComponent c)
          Tests if the component can have the focus.
 void keyPressed(LwKeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(LwKeyEvent e)
          Invoked when a key has been released.
 void keyTyped(LwKeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(LwMouseEvent e)
          Invoked when the mouse has been clicked on a light weight component.
 void mouseEntered(LwMouseEvent e)
          Invoked when the mouse enters a light weight component.
 void mouseExited(LwMouseEvent e)
          Invoked when the mouse exits a light weight component.
 void mousePressed(LwMouseEvent e)
          Invoked when the mouse has been pressed on a light weight component.
 void mouseReleased(LwMouseEvent e)
          Invoked when the mouse has been released on a light weight component.
 void requestFocus(LwComponent c)
          Requests the input focus for the specified component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LwFocusManager

public LwFocusManager()
Method Detail

requestFocus

public void requestFocus(LwComponent c)
Requests the input focus for the specified component. The component can be the focus owner if it is visible and enabled. If the focus owner has been changed than appropriate focus lost and gained event will be performed and passed to LwEventManager.
Parameters:
c - the specified component.

findFocusable

public LwComponent findFocusable(LwComponent c)
Looks for a component that can be the focus owner starting from the specified component.
Parameters:
c - the specified starting component.
Returns:
the component that can be the focus owner or null if the component has not been found.

hasFocus

public boolean hasFocus(LwComponent c)
Tests if the specified component has the focus.
Parameters:
c - the specified component.
Returns:
true if the component is a focus owner; otherwise false.

getFocusOwner

public LwComponent getFocusOwner()
Gets the focus owner component.
Returns:
a focus owner component.

mousePressed

public void mousePressed(LwMouseEvent e)
Invoked when the mouse has been pressed on a light weight component. The manager uses the method to set the source component as the focus owner if it is possible.
Specified by:
mousePressed in interface LwMouseListener
Parameters:
e - the specified mouse event.

mouseClicked

public void mouseClicked(LwMouseEvent e)
Invoked when the mouse has been clicked on a light weight component.
Specified by:
mouseClicked in interface LwMouseListener
Parameters:
e - the specified mouse event.

mouseEntered

public void mouseEntered(LwMouseEvent e)
Invoked when the mouse enters a light weight component.
Specified by:
mouseEntered in interface LwMouseListener
Parameters:
e - the specified mouse event.

mouseExited

public void mouseExited(LwMouseEvent e)
Invoked when the mouse exits a light weight component.
Specified by:
mouseExited in interface LwMouseListener
Parameters:
e - the specified mouse event.

mouseReleased

public void mouseReleased(LwMouseEvent e)
Invoked when the mouse has been released on a light weight component.
Specified by:
mouseReleased in interface LwMouseListener
Parameters:
e - the specified mouse event.

compDisabled

public void compDisabled(LwComponentEvent e)
Invoked when the light weight component has been disabled. The method clears the focus owner if the owner is a source of the event.
Specified by:
compDisabled in interface LwComponentListener
Parameters:
e - the specified component event.

compEnabled

public void compEnabled(LwComponentEvent e)
Invoked when the light weight component has been enabled.
Specified by:
compEnabled in interface LwComponentListener
Parameters:
e - the specified component event.

compShown

public void compShown(LwComponentEvent e)
Invoked when the light weight component has been shown.
Specified by:
compShown in interface LwComponentListener
Parameters:
e - the specified component event.

compHidden

public void compHidden(LwComponentEvent e)
Invoked when the light weight component has been hidden. The method clears the focus owner if the owner is the source of the event.
Specified by:
compHidden in interface LwComponentListener
Parameters:
e - the specified component event.

compAdded

public void compAdded(LwContainerEvent e)
Invoked when the light weight component has been added to the container.
Specified by:
compAdded in interface LwContainerListener
Parameters:
e - the specified container event.

compRemoved

public void compRemoved(LwContainerEvent e)
Invoked when the light weight component has been removed from the container. The method clears the focus owner if the owner is the source of the event.
Specified by:
compRemoved in interface LwContainerListener
Parameters:
e - the specified container event.

keyPressed

public void keyPressed(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been pressed.
Specified by:
keyPressed in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyReleased

public void keyReleased(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been released.
Specified by:
keyReleased in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyTyped

public void keyTyped(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been typed.
Specified by:
keyTyped in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

dispose

public void dispose()
Specified by:
dispose in interface LwManager

isFocusable

protected boolean isFocusable(LwComponent c)
Tests if the component can have the focus.
Parameters:
c - the specified component to test.
Returns:
true if the component can have the focus.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org