|
qflib 0.98.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--javax.swing.FocusManager
|
+--javax.swing.DefaultFocusManager
|
+--de.qfs.lib.gui.FocusFixer
This class fixes an annoying bug that only occurs in JDK 1.1 with the motif Toolkit. In that constellation, whenever a window loses the focus it forgets which component had the focus last. When the window regains the focus, no component is focused and navigation with the tab key restarts at the first component.
To fix this problem, FocusFixer extends DefaultFocusManager to keep track of
focused components and implements WindowListener in order to return the focus to the right component when a
window is opened or activated.
To fix focus management for any Window, simply get a FocusFixer instance
with instance and use its addWindow
method. Don't forget to remove the window with removeWindow when you are getting rid of it.
You can use FocusFixer regardless of what JDK you use and what operating system resp. what AWT Toolkit you are running on. If it is not the JDK 1.1 motif combination, FocusFixer will silently ignore all calls.
| Fields inherited from class javax.swing.FocusManager |
FOCUS_MANAGER_CLASS_PROPERTY |
| Method Summary | |
void |
addWindow(java.awt.Window window)
Register a window with a FocusFixer so it will keep track of the focus owner and restore the focus whenever the window is openened or activated. |
void |
focusNextComponent(java.awt.Component com)
Focus the next component. |
void |
focusPreviousComponent(java.awt.Component com)
Focus the previous component. |
static FocusFixer |
instance()
Get the FocusFixer instance for the ThreadGroup of the calling Thread. |
void |
processKeyEvent(java.awt.Component com,
java.awt.event.KeyEvent e)
Process one key event. |
void |
removeWindow(java.awt.Window window)
Remove a window from a FocusFixer so it will no longer handle its focus. |
void |
windowActivated(java.awt.event.WindowEvent e)
Restore the focus to the recent focus owner. |
void |
windowClosed(java.awt.event.WindowEvent e)
Does nothing. |
void |
windowClosing(java.awt.event.WindowEvent e)
Does nothing. |
void |
windowDeactivated(java.awt.event.WindowEvent e)
Does nothing. |
void |
windowDeiconified(java.awt.event.WindowEvent e)
Does nothing. |
void |
windowIconified(java.awt.event.WindowEvent e)
Does nothing. |
void |
windowOpened(java.awt.event.WindowEvent e)
Restore the focus to the recent focus owner. |
| Methods inherited from class javax.swing.DefaultFocusManager |
compareTabOrder, getComponentAfter, getComponentBefore, getFirstComponent, getLastComponent |
| Methods inherited from class javax.swing.FocusManager |
disableSwingFocusManager, getCurrentManager, isFocusManagerEnabled, setCurrentManager |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static FocusFixer instance()
FocusManager.setCurrentManager(javax.swing.FocusManager)public void addWindow(java.awt.Window window)
removeWindow when the
window is disposed in order to clean up all references to it.window - The window to register.public void removeWindow(java.awt.Window window)
window - The window to remove.public void windowActivated(java.awt.event.WindowEvent e)
windowActivated in interface java.awt.event.WindowListenere - The event containing the details.public void windowOpened(java.awt.event.WindowEvent e)
windowOpened in interface java.awt.event.WindowListenere - The event containing the details.public void windowDeactivated(java.awt.event.WindowEvent e)
windowDeactivated in interface java.awt.event.WindowListenere - The event containing the details.public void windowClosed(java.awt.event.WindowEvent e)
windowClosed in interface java.awt.event.WindowListenere - The event containing the details.public void windowClosing(java.awt.event.WindowEvent e)
windowClosing in interface java.awt.event.WindowListenere - The event containing the details.public void windowIconified(java.awt.event.WindowEvent e)
windowIconified in interface java.awt.event.WindowListenere - The event containing the details.public void windowDeiconified(java.awt.event.WindowEvent e)
windowDeiconified in interface java.awt.event.WindowListenere - The event containing the details.
public void processKeyEvent(java.awt.Component com,
java.awt.event.KeyEvent e)
processKeyEvent in class javax.swing.DefaultFocusManagercom - The component on which the key event occured.e - The event.public void focusNextComponent(java.awt.Component com)
focusNextComponent in class javax.swing.DefaultFocusManagercom - Focus the component that is next in the focus order
from this one.public void focusPreviousComponent(java.awt.Component com)
focusPreviousComponent in class javax.swing.DefaultFocusManagercom - Focus the component that is the previous one from
this one in the focus order.
|
qflib 0.98.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||