|
|
@ -44,10 +44,13 @@ public final class FocusParentHelper { |
|
|
|
if (e.getID() != FocusEvent.FOCUS_GAINED && e.getID() != FocusEvent.FOCUS_LOST) return; |
|
|
|
if (e.getID() != FocusEvent.FOCUS_GAINED && e.getID() != FocusEvent.FOCUS_LOST) return; |
|
|
|
Component comp = e.getComponent(); |
|
|
|
Component comp = e.getComponent(); |
|
|
|
listeners.forEach((c, focusParent) -> { |
|
|
|
listeners.forEach((c, focusParent) -> { |
|
|
|
if (c instanceof JComponent && SwingUtilities.isDescendingFrom(comp, focusParent)) { |
|
|
|
if (SwingUtilities.isDescendingFrom(comp, focusParent)) { |
|
|
|
RepaintAction repaintAction = PropertyUtil.getObject(c, KEY_FOCUS_ACTION, RepaintAction.class); |
|
|
|
OnFocusChangedAction onFocusChangedAction = |
|
|
|
if (repaintAction != null) { |
|
|
|
PropertyUtil.getObject(c, KEY_FOCUS_ACTION, OnFocusChangedAction.class); |
|
|
|
repaintAction.accept(c); |
|
|
|
if (onFocusChangedAction != null) { |
|
|
|
|
|
|
|
onFocusChangedAction.accept(c); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
c.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -68,7 +71,7 @@ public final class FocusParentHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void setFocusParent(final JComponent c, final JComponent focusParent, |
|
|
|
public static void setFocusParent(final JComponent c, final JComponent focusParent, |
|
|
|
final RepaintAction focusChangedAction) { |
|
|
|
final OnFocusChangedAction focusChangedAction) { |
|
|
|
if (c == null) return; |
|
|
|
if (c == null) return; |
|
|
|
c.putClientProperty(KEY_FOCUS_PARENT, focusParent); |
|
|
|
c.putClientProperty(KEY_FOCUS_PARENT, focusParent); |
|
|
|
updateFocusParentRegistry(c, focusParent); |
|
|
|
updateFocusParentRegistry(c, focusParent); |
|
|
@ -77,6 +80,6 @@ public final class FocusParentHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public interface RepaintAction extends Consumer<Component> { |
|
|
|
public interface OnFocusChangedAction extends Consumer<Component> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|