public final class EditorRegistry extends Object
JTextComponent
s in most-recently-used order.
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_REMOVED_PROPERTY
Fired when a component (returned previously from
EditorRegistry.componentList() )
is removed from component hierarchy (so it's likely that the component will be released completely
and garbage-collected). |
static String |
FOCUS_GAINED_PROPERTY
Fired when focus was delivered to a registered text component.
|
static String |
FOCUS_LOST_PROPERTY
Fired when a registered focused component has lost the focus.
|
static String |
FOCUSED_DOCUMENT_PROPERTY
Fired when document property of the focused component changes
i.e.
|
static String |
LAST_FOCUSED_REMOVED_PROPERTY
Fired when the last focused component (returned previously from
EditorRegistry.lastFocusedComponent() )
was removed from component hierarchy (so it's likely that the component will be released completely
and garbage-collected). |
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener for either of the following properties:
EditorRegistry.FOCUS_GAINED_PROPERTY
EditorRegistry.FOCUS_LOST_PROPERTY
EditorRegistry.FOCUSED_DOCUMENT_PROPERTY
. |
static List<? extends JTextComponent> |
componentList()
Get list of all components present in the registry starting with the most active
and ending with least active component.
|
static JTextComponent |
findComponent(Document doc)
Find a component that uses the given document.
|
static JTextComponent |
focusedComponent()
Return the last focused component if it currently has a focus
or return null if none of the registered components currently have the focus.
|
static JTextComponent |
lastFocusedComponent()
Return last focused text component (from the ones included in the registry).
|
static void |
removePropertyChangeListener(PropertyChangeListener l) |
public static final String FOCUS_GAINED_PROPERTY
PropertyChangeEvent.getOldValue()
will be a component
losing the focus FocusEvent.getOppositeComponent()
.
The PropertyChangeEvent.getNewValue()
will be the text component gaining the focus.public static final String FOCUS_LOST_PROPERTY
PropertyChangeEvent.getOldValue()
will be the text component
losing the focus and the PropertyChangeEvent.getNewValue()
will be the component gaining the focus FocusEvent.getOppositeComponent()
.public static final String FOCUSED_DOCUMENT_PROPERTY
JTextComponent.setDocument(Document)
.
PropertyChangeEvent.getOldValue()
will be the original document
of the focused text component and the PropertyChangeEvent.getNewValue()
will be the new document set to the focused text component.public static final String COMPONENT_REMOVED_PROPERTY
EditorRegistry.componentList()
)
is removed from component hierarchy (so it's likely that the component will be released completely
and garbage-collected).
EditorRegistry.componentList()
or EditorRegistry.lastFocusedComponent()
.
PropertyChangeEvent.getOldValue()
will be the removed
component.
PropertyChangeEvent.getNewValue()
returns null
public static final String LAST_FOCUSED_REMOVED_PROPERTY
EditorRegistry.lastFocusedComponent()
)
was removed from component hierarchy (so it's likely that the component will be released completely
and garbage-collected).
EditorRegistry.componentList()
or EditorRegistry.lastFocusedComponent()
.
PropertyChangeEvent.getOldValue()
will be the removed
last focused component and the PropertyChangeEvent.getNewValue()
will be the component that would currently be returned from EditorRegistry.lastFocusedComponent()
.
PropertyChangeEvent.getNewValue()
returns null
then there are no longer any registered components
(EditorRegistry.componentList()
would return empty list). If the client
holds per-last-focused-component data it should clear them.public static JTextComponent lastFocusedComponent()
public static JTextComponent focusedComponent()
public static List<? extends JTextComponent> componentList()
public static JTextComponent findComponent(Document doc)
JTextComponent.getDocument()
returns the document passed
as parameter to this method and if so return the component.public static void addPropertyChangeListener(PropertyChangeListener l)
EditorRegistry.FOCUS_GAINED_PROPERTY
EditorRegistry.FOCUS_LOST_PROPERTY
EditorRegistry.FOCUSED_DOCUMENT_PROPERTY
l
- non-null listener to add.public static void removePropertyChangeListener(PropertyChangeListener l)