private void setFocused(boolean focused) { boolean old = isFocused(); this.focused = focused; firePropertyChange("focused", old, isFocused()); }
/** * Removes all property change listeners which are registered with this instance. */ private void removeAllListeners() { for (PropertyChangeListener l : getPropertyChangeListeners()) { removePropertyChangeListener(l); } }
/** * Releases all listeners and internal references.<p> * * <b>Note</b>: this instance must not be used after calling this method. * */ public void release() { removeManagerListener(KeyboardFocusManager.getCurrentKeyboardFocusManager()); removeAllListeners(); this.root = null; }
/** * Instantiates a CompoundFocusListener on the component hierarchy below the given * component. * * @param root the root of a component hierarchy * @throws NullPointerException if the root is null */ public CompoundFocusListener(JComponent root) { this.root = Contract.asNotNull(root, "root must not be null"); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); addManagerListener(manager); permanentFocusOwnerChanged(manager.getPermanentFocusOwner()); }
/** * Removes all listeners this instance has installed from the given KeyboardFocusManager.<p> * * @param manager the KeyboardFocusManager to remove internal listeners from. * @see #addManagerListener(KeyboardFocusManager) */ private void removeManagerListener(KeyboardFocusManager manager) { manager.removePropertyChangeListener("permanentFocusOwner", getManagerListener()); }
public void propertyChange(PropertyChangeEvent evt) { if ("permanentFocusOwner".equals(evt.getPropertyName())) { permanentFocusOwnerChanged((Component) evt.getNewValue()); } }}; }
/** * Updates focused property depending on whether or not the given component * is below the root's hierarchy. <p> * * Note: Does nothing if the component is null. This might not be entirely correct, * but property change events from the focus manager come in pairs, with only * one of the new/old value not-null. * * @param focusOwner the component with is the current focusOwner. */ protected void permanentFocusOwnerChanged(Component focusOwner) { if (focusOwner == null) return; setFocused(SwingXUtilities.isDescendingFrom(focusOwner, root)); }
/** * Instantiates a CompoundFocusListener on the component hierarchy below the given * component. * * @param root the root of a component hierarchy * @throws NullPointerException if the root is null */ public CompoundFocusListener(JComponent root) { this.root = Contract.asNotNull(root, "root must not be null"); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); addManagerListener(manager); permanentFocusOwnerChanged(manager.getPermanentFocusOwner()); }
/** * Adds all listeners to the given KeyboardFocusManager. <p> * * @param manager the KeyboardFocusManager to add internal listeners to. * @see #removeManagerListener(KeyboardFocusManager) */ private void addManagerListener(KeyboardFocusManager manager) { manager.addPropertyChangeListener("permanentFocusOwner", getManagerListener()); }
@Override public void propertyChange(PropertyChangeEvent evt) { if ("permanentFocusOwner".equals(evt.getPropertyName())) { permanentFocusOwnerChanged((Component) evt.getNewValue()); } }}; }
/** * Updates focused property depending on whether or not the given component * is below the root's hierarchy. <p> * * Note: Does nothing if the component is null. This might not be entirely correct, * but property change events from the focus manager come in pairs, with only * one of the new/old value not-null. * * @param focusOwner the component with is the current focusOwner. */ protected void permanentFocusOwnerChanged(Component focusOwner) { if (focusOwner == null) return; setFocused(SwingXUtilities.isDescendingFrom(focusOwner, root)); }
private void setFocused(boolean focused) { boolean old = isFocused(); this.focused = focused; firePropertyChange("focused", old, isFocused()); }
/** * Releases all listeners and internal references.<p> * * <b>Note</b>: this instance must not be used after calling this method. * */ public void release() { removeManagerListener(KeyboardFocusManager.getCurrentKeyboardFocusManager()); removeAllListeners(); this.root = null; }
/** * Removes all property change listeners which are registered with this instance. */ private void removeAllListeners() { for (PropertyChangeListener l : getPropertyChangeListeners()) { removePropertyChangeListener(l); } }
/** * Instantiates a CompoundFocusListener on the component hierarchy below the given * component. * * @param root the root of a component hierarchy * @throws NullPointerException if the root is null */ public CompoundFocusListener(JComponent root) { this.root = Contract.asNotNull(root, "root must not be null"); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); addManagerListener(manager); permanentFocusOwnerChanged(manager.getPermanentFocusOwner()); }
/** * Removes all listeners this instance has installed from the given KeyboardFocusManager.<p> * * @param manager the KeyboardFocusManager to remove internal listeners from. * @see #addManagerListener(KeyboardFocusManager) */ private void removeManagerListener(KeyboardFocusManager manager) { manager.removePropertyChangeListener("permanentFocusOwner", getManagerListener()); }
@Override public void propertyChange(PropertyChangeEvent evt) { if ("permanentFocusOwner".equals(evt.getPropertyName())) { permanentFocusOwnerChanged((Component) evt.getNewValue()); } }}; }
/** * Updates focused property depending on whether or not the given component * is below the root's hierarchy. <p> * * Note: Does nothing if the component is null. This might not be entirely correct, * but property change events from the focus manager come in pairs, with only * one of the new/old value not-null. * * @param focusOwner the component with is the current focusOwner. */ protected void permanentFocusOwnerChanged(Component focusOwner) { if (focusOwner == null) return; setFocused(SwingXUtilities.isDescendingFrom(focusOwner, root)); }
private void setFocused(boolean focused) { boolean old = isFocused(); this.focused = focused; firePropertyChange("focused", old, isFocused()); }
/** * Releases all listeners and internal references.<p> * * <b>Note</b>: this instance must not be used after calling this method. * */ public void release() { removeManagerListener(KeyboardFocusManager.getCurrentKeyboardFocusManager()); removeAllListeners(); this.root = null; }