📄 keyboardfocusmanager.java
字号:
if (l != null) propertyChangeSupport.removePropertyChangeListener(l); } /** * Returns the currently registered property change listeners * in array form. The returned array is empty if no listeners are * currently registered. * * @return an array of registered property change listeners. */ public PropertyChangeListener[] getPropertyChangeListeners() { return propertyChangeSupport.getPropertyChangeListeners(); } /** * Registers a property change listener for receiving events relating * to a change to a specified property. The supplied property name can be * either user-defined or one from the following list of properties * relevant to this class: * * <ul> * <li>the current focus owner ("focusOwner")</li> * <li>the permanent focus owner ("permanentFocusOwner")</li> * <li>the focused window ("focusedWindow")</li> * <li>the active window ("activeWindow")</li> * <li>the default focus traversal policy ("defaultFocusTraversalPolicy")</li> * <li>the default set of forward traversal keys ("forwardDefaultFocusTraversalKeys")</li> * <li>the default set of backward traversal keys ("backwardDefaultFocusTraversalKeys")</li> * <li>the default set of up cycle traversal keys ("upCycleDefaultFocusTraversalKeys")</li> * <li>the default set of down cycle traversal keys ("downCycleDefaultFocusTraversalKeys")</li> * <li>the current focus cycle root ("currentFocusCycleRoot")</li> * </ul> * * Nothing occurs if a null listener is supplied. null is regarded as a valid property name. * * @param name the name of the property to handle change events for. * @param l the listener to register for changes to the specified property. * @see KeyboardFocusManager#addPropertyChangeListener(java.beans.PropertyChangeListener) */ public void addPropertyChangeListener(String name, PropertyChangeListener l) { if (l != null) propertyChangeSupport.addPropertyChangeListener(name, l); } /** * Removes the supplied property change listener registered for the * specified property from the list of registered listeners. If the * supplied listener is null, nothing occurs. * * @param name the name of the property the listener is * monitoring changes to. * @param l the listener to remove. */ public void removePropertyChangeListener(String name, PropertyChangeListener l) { if (l != null) propertyChangeSupport.removePropertyChangeListener(name, l); } /** * Returns the currently registered property change listeners * in array form, which listen for changes to the supplied property. * The returned array is empty, if no listeners are currently registered * for events pertaining to the supplied property. * * @param name The property the returned listeners monitor for changes. * @return an array of registered property change listeners which * listen for changes to the supplied property. */ public PropertyChangeListener[] getPropertyChangeListeners(String name) { return propertyChangeSupport.getPropertyChangeListeners(name); } /** * Fires a property change event as a response to a change to * to the specified property. The event is only fired if a * change has actually occurred (i.e. o and n are different). * * @param name The name of the property to which a change occurred. * @param o The old value of the property. * @param n The new value of the property. */ protected void firePropertyChange(String name, Object o, Object n) { propertyChangeSupport.firePropertyChange(name, o, n); } /** * Registers a vetoable property change listener for receiving events * relating to the following properties: * * <ul> * <li>the current focus owner ("focusOwner")</li> * <li>the permanent focus owner ("permanentFocusOwner")</li> * <li>the focused window ("focusedWindow")</li> * <li>the active window ("activeWindow")</li> * </ul> * * Nothing occurs if a null listener is supplied. * * @param l the listener to register. * @see KeyboardFocusManager#addVetoableChangeListener(String, java.beans.VetoableChangeListener) */ public void addVetoableChangeListener(VetoableChangeListener l) { if (l != null) vetoableChangeSupport.addVetoableChangeListener(l); } /** * Removes the supplied vetoable property change listener from * the list of registered listeners. If the supplied listener * is null, nothing occurs. * * @param l the listener to remove. */ public void removeVetoableChangeListener(VetoableChangeListener l) { if (l != null) vetoableChangeSupport.removeVetoableChangeListener(l); } /** * Returns the currently registered vetoable property change listeners * in array form. The returned array is empty if no listeners are * currently registered. * * @return an array of registered vetoable property change listeners. * @since 1.4 */ public VetoableChangeListener[] getVetoableChangeListeners() { return vetoableChangeSupport.getVetoableChangeListeners(); } /** * Registers a vetoable property change listener for receiving events relating * to a vetoable change to a specified property. The supplied property name can be * either user-defined or one from the following list of properties * relevant to this class: * * <ul> * <li>the current focus owner ("focusOwner")</li> * <li>the permanent focus owner ("permanentFocusOwner")</li> * <li>the focused window ("focusedWindow")</li> * <li>the active window ("activeWindow")</li> * </ul> * * Nothing occurs if a null listener is supplied. null is regarded as a valid property name. * * @param name the name of the property to handle change events for. * @param l the listener to register for changes to the specified property. * @see KeyboardFocusManager#addVetoableChangeListener(java.beans.VetoableChangeListener) */ public void addVetoableChangeListener(String name, VetoableChangeListener l) { if (l != null) vetoableChangeSupport.addVetoableChangeListener(name, l); } /** * Removes the supplied vetoable property change listener registered * for the specified property from the list of registered listeners. * If the supplied listener is null, nothing occurs. * * @param name the name of the vetoable property the listener is * monitoring changes to. * @param l the listener to remove. */ public void removeVetoableChangeListener(String name, VetoableChangeListener l) { if (l != null) vetoableChangeSupport.removeVetoableChangeListener(name, l); } /** * Returns the currently registered vetoable property change listeners * in array form, which listen for changes to the supplied property. * The returned array is empty, if no listeners are currently registered * for events pertaining to the supplied property. * * @param name The property the returned listeners monitor for changes. * @return an array of registered property change listeners which * listen for changes to the supplied property. * @since 1.4 */ public VetoableChangeListener[] getVetoableChangeListeners(String name) { return vetoableChangeSupport.getVetoableChangeListeners(name); } /** * Fires a property change event as a response to a vetoable change to * to the specified property. The event is only fired if a * change has actually occurred (i.e. o and n are different). * In the event that the property change is vetoed, the following * occurs: * * <ol> * <li> * This method throws a <code>PropertyVetoException</code> to * the proposed change. * </li> * <li> * A new event is fired to reverse the previous change. * </li> * <li> * This method again throws a <code>PropertyVetoException</code> * in response to the reversion. * </li> * </ol> * * @param name The name of the property to which a change occurred. * @param o The old value of the property. * @param n The new value of the property. * @throws PropertyVetoException if one of the listeners vetos * the change by throwing this exception. */ protected void fireVetoableChange(String name, Object o, Object n) throws PropertyVetoException { vetoableChangeSupport.fireVetoableChange(name, o, n); } /** * Adds a key event dispatcher to the list of registered dispatchers. * When a key event is fired, each dispatcher's <code>dispatchKeyEvent</code> * method is called in the order that they were added, prior to the manager * dispatching the event itself. Notifications halt when one of the * dispatchers returns true. * <br /> * <br /> * The same dispatcher can exist multiple times within the list * of registered dispatchers, and there is no limit on the length * of this list. A null dispatcher is simply ignored. * * @param dispatcher The dispatcher to register. */ public void addKeyEventDispatcher(KeyEventDispatcher dispatcher) { if (dispatcher != null) keyEventDispatchers.add(dispatcher); } /** * Removes the specified key event dispatcher from the list of * registered dispatchers. The manager always dispatches events, * regardless of its existence within the list. The manager * can be added and removed from the list, as with any other * dispatcher, but this does not affect its ability to dispatch * key events. Non-existent and null dispatchers are simply ignored * by this method. * * @param dispatcher The dispatcher to remove. */ public void removeKeyEventDispatcher(KeyEventDispatcher dispatcher) { keyEventDispatchers.remove(dispatcher); } /** * Returns the currently registered key event dispatchers in <code>List</code> * form. At present, this only includes dispatchers explicitly registered * via the <code>addKeyEventDispatcher()</code> method, but this behaviour * is subject to change and should not be depended on. The manager itself * may be a member of the list, but only if explicitly registered. If no * dispatchers have been registered, the list will be empty. * * @return A list of explicitly registered key event dispatchers. * @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher) */ protected List getKeyEventDispatchers () { return (List) keyEventDispatchers.clone (); } /** * Adds a key event post processor to the list of registered post processors. * Post processors work in the same way as key event dispatchers, except * that they are invoked after the manager has dispatched the key event, * and not prior to this. Each post processor's <code>postProcessKeyEvent</code> * method is called to see if any post processing needs to be performed. THe * processors are called in the order in which they were added to the list, * and notifications continue until one returns true. As with key event * dispatchers, the manager is implicitly called following this process, * regardless of whether or not it is present within the list. * <br /> * <br /> * The same post processor can exist multiple times within the list * of registered post processors, and there is no limit on the length * of this list. A null post processor is simply ignored. * * @param postProcessor the post processor to register. * @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher) */ public void addKeyEventPostProcessor (KeyEventPostProcessor postProcessor) { if (postProcessor != null) keyEventPostProcessors.add (postProcessor); } /** * Removes the specified key event post processor from the list of * registered post processors. The manager always post processes events, * regardless of its existence within the list. The manager * can be added and removed from the list, as with any other * post processor, but this does not affect its ability to post process * key events. Non-existent and null post processors are simply ignored * by this method. * * @param postProcessor the post processor to remove. */ public void removeKeyEventPostProcessor (KeyEventPostProcessor postProcessor) { keyEventPostProcessors.remove (postProcessor); } /** * Returns the currently registered key event post processors in <code>List</code> * form. At present, this only includes post processors explicitly registered * via the <code>addKeyEventPostProcessor()</code> method, but this behaviour * is subject to change and should not be depended on. The manager itself * may be a member of the list, but only if explicitly registered. If no * post processors have been registered, the list will be empty. * * @return A list of explicitly registered key event post processors. * @see KeyboardFocusManager#addKeyEventPostProcessor(java.awt.KeyEventPostProcessor) */ protected List getKeyEventPostProcessors () { return (List) keyEventPostProcessors.clone (); } /** * The AWT event dispatcher uses this method to request that the manager * handle a particular event. If the manager fails or refuses to * dispatch the supplied event (this method returns false), the * AWT event dispatcher will try to dispatch the event itself. * <br /> * <br /> * The manager is expected to handle all <code>FocusEvent</code>s * and <code>KeyEvent</code>s, and <code>WindowEvent</code>s * relating to the focus. Dispatch is done with regard to the * the focus owner and the currently focused and active windows. * In handling the event, the source of the event may be overridden. * <br /> * <br /> * The actual dispatching is performed by calling * <code>redispatchEvent()</code>. This avoids the infinite recursion * of dispatch requests which may occur if this method is called on * the target component. * * @param e the event to dispatch. * @return true if the event was dispatched.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -