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 library.
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:
-
requestFocus. The method is called to try pass the focus to the specified
component or some other component. The method tests if the specified component
can have focus by the isFocusable method.
-
hasFocus. The method is called to test if the component has the focus or not.
-
getFocusOwner. The method returns a component which has the focus.
-
findFocusable. The method looks for a component that can get the focus.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LwFocusManager
public LwFocusManager()
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(LwVCLEvent 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(LwVCLEvent 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(LwVCLEvent 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(LwVCLEvent 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()
- Description copied from interface:
LwManager
- Disposes the manager. The method is supposed to be used for disposing different manager related structures
to free system resources. The method is invoked by LwVCL core when the manager ends its "live".
- 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.
|