public abstract class DefaultFocusTracker extends Object implements FocusTracker
FocusTracker
implementation for FocusTracker
usage convenience.
This implementation also offers customization of additional focusable Component
s attached to tracked JComponent
.FocusManager
Modifier and Type | Field and Description |
---|---|
protected JComponent |
component
Tracked
JComponent . |
protected boolean |
enabled
Whether or not tracking is currently enabled.
|
protected Set<Component> |
focusableChildren
Additional focusable children which should be tracked in addition to the main tracked
JComponent . |
protected boolean |
focused
Whether or not tracked
JComponent is currently focused according to this tracker settings. |
protected boolean |
uniteWithChildren
Whether or not tracked
JComponent and its children should be counted as a single focusable unit. |
Constructor and Description |
---|
DefaultFocusTracker(JComponent component,
boolean uniteWithChildren)
Constructs new
DefaultFocusTracker . |
Modifier and Type | Method and Description |
---|---|
void |
addFocusableChild(Component child)
Adds new focusable child
Component . |
List<Component> |
getFocusableChildren()
Returns additional focusable children which should be tracked in addition to the main tracked
JComponent . |
protected boolean |
isChildInvolved(Component tracked,
Component component)
|
boolean |
isEnabled()
Returns whether or not tracking is currently enabled.
|
protected boolean |
isEqual(Component tracked,
Component component)
|
protected boolean |
isEqualOrChild(Component tracked,
Component component)
|
boolean |
isFocused()
Returns whether or not tracked component is currently focused according to this tracker settings.
|
boolean |
isInvolved(JComponent tracked,
Component component)
Returns whether specified
Component is involved with this tracked JComponent or not. |
protected boolean |
isRelated(Component tracked,
Component component)
|
protected boolean |
isTrackingWindow(Component tracked)
|
boolean |
isUniteWithChildren()
Returns whether or not tracked
JComponent and its children should be counted as a single focusable unit. |
void |
removeFocusableChild(Component child)
Removes focusable child
Component . |
void |
setEnabled(boolean enabled)
Sets whether or not tracking is currently enabled.
|
void |
setFocused(boolean focused)
Sets tracked component focused state.
|
void |
setUniteWithChildren(boolean unite)
Sets whether or not tracked
JComponent and its children should be counted as a single focusable unit. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
focusChanged
@NotNull protected final JComponent component
JComponent
.protected boolean uniteWithChildren
JComponent
and its children should be counted as a single focusable unit.
In case component and its children are counted as one unit - focus changes between them will be ignored by tracker.@Nullable protected Set<Component> focusableChildren
JComponent
.
Note that this Set
is backed by WeakHashSet
implementation to avoid any memory leaks.
So it is safe to add any components here, even ones that might be removed at some point.protected boolean enabled
protected boolean focused
JComponent
is currently focused according to this tracker settings.public DefaultFocusTracker(@NotNull JComponent component, boolean uniteWithChildren)
DefaultFocusTracker
.component
- tracked JComponent
uniteWithChildren
- whether or not tracked JComponent
and its children should be counted as a single focusable unitpublic boolean isUniteWithChildren()
JComponent
and its children should be counted as a single focusable unit.
In case component and its children are counted as one unit - focus changes between them will be ignored by tracker.true
if tracked JComponent
and its children should be counted as a single focusable unit, false
otherwisepublic void setUniteWithChildren(boolean unite)
JComponent
and its children should be counted as a single focusable unit.
In case component and its children are counted as one unit - focus changes between them will be ignored by tracker.unite
- whether or not tracked JComponent
and its children should be counted as a single focusable unit@NotNull public List<Component> getFocusableChildren()
JComponent
.
Note that uniteWithChildren
setting also affects how these children focus is checked.public void addFocusableChild(@NotNull Component child)
Component
.
Note that uniteWithChildren
setting also affects how these children focus is checked.child
- focusable child Component
to addpublic void removeFocusableChild(@NotNull Component child)
Component
.
Note that uniteWithChildren
setting also affects how these children focus is checked.child
- focusable child Component
to removepublic boolean isEnabled()
FocusTracker
isEnabled
in interface FocusTracker
true
if tracking is currently enabled, false
otherwisepublic void setEnabled(boolean enabled)
FocusTracker
setEnabled
in interface FocusTracker
enabled
- whether or not tracking is currently enabledpublic boolean isFocused()
FocusTracker
isFocused
in interface FocusTracker
true
if tracked component is currently focused according to this tracker settings, false
otherwisepublic void setFocused(boolean focused)
FocusTracker
setFocused
in interface FocusTracker
focused
- component focused statepublic boolean isInvolved(@NotNull JComponent tracked, @Nullable Component component)
FocusTracker
Component
is involved with this tracked JComponent
or not.
It basically says whether or not specified Component
counts towards tracked JComponent
focus changes.isInvolved
in interface FocusTracker
tracked
- tracked JComponent
component
- Component
to check for involvementtrue
if specified Component
is involved with this tracked JComponent
, false
otherwiseprotected boolean isChildInvolved(@NotNull Component tracked, @NotNull Component component)
protected boolean isEqualOrChild(@NotNull Component tracked, @NotNull Component component)
Copyright © 2020. All rights reserved.