public class FocusSnitch
extends java.lang.Object
implements java.beans.PropertyChangeListener
This class implements PropertyChangeListener to "snitch" on the
KeyboardFocusManager. It listens for changes in focus-related properties
and logs detailed information about these events, including which component
gained focus and the window it belongs to. This is especially useful for
diagnosing problems with focus traversal or components unexpectedly losing focus.
The logger is configured to log at "INFO" level and includes a stack trace
(even though it's typically uninteresting as it comes from the EDT) to provide
context for the log entry.
| Constructor and Description |
|---|
FocusSnitch()
Constructs a new `FocusSnitch` and registers it as a
PropertyChangeListener with the current "KeyboardFocusManager". |
| Modifier and Type | Method and Description |
|---|---|
void |
propertyChange(java.beans.PropertyChangeEvent pce)
Invoked when a focus-related property changes.
|
public FocusSnitch()
PropertyChangeListener with the current "KeyboardFocusManager".
This ensures that `propertyChange` will be invoked whenever a focus property changes within the application's Swing environment.
public void propertyChange(java.beans.PropertyChangeEvent pce)
This method filters out events where the new value is null and then
logs the property name and the new value. It uses the tool method
FormElementI.toDebugName(Object) to format the component or window
for a more readable log message.
A stack trace is included to help trace the event's origin, even though
it typically originates from the Event Dispatch Thread (EDT) and might
not reveal a great deal of useful information.
propertyChange in interface java.beans.PropertyChangeListenerpce - The PropertyChangeEvent describing the property change.Copyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.