⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyboardfocusmanager.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   * @see KeyboardFocusManager#redispatchEvent(java.awt.Component, java.awt.AWTEvent)   * @see KeyEvent   * @see FocusEvent   * @see WindowEvent   */  public abstract boolean dispatchEvent (AWTEvent e);  /**   * Handles redispatching of an event so that recursion of   * dispatch requests does not occur.  Event dispatch methods   * within this manager (<code>dispatchEvent()</code>) and   * the key event dispatchers should use this method to handle   * dispatching rather than the dispatch method of the target   * component.     * <br />   * <br />   * <strong>   * This method is not intended for general consumption, and is   * only for the use of the aforementioned classes.   * </strong>   *    * @param target the target component to which the event is   *        dispatched.   * @param e the event to dispatch.   */  public final void redispatchEvent (Component target, AWTEvent e)  {    synchronized (e)      {        e.setSource (target);        target.dispatchEvent (e);      }  }  /**   * Attempts to dispatch key events for which no key event dispatcher   * has so far succeeded.  This method is usually called by   * <code>dispatchEvent()</code> following the sending of the key   * event to any registered key event dispatchers.  If the key   * event reaches this stage, none of the dispatchers returned   * true.  This is, of course, always the case if there are no   * registered dispatchers.   * <br />   * <br />   * If this method also fails to handle the key event, then   * false is returned to the caller.  In the case of   * <code>dispatchEvent()</code>, the calling method may try   * to handle the event itself or simply forward on the   * false result to its caller.  When the event is dispatched   * by this method, a true result is propogated through the   * calling methods.   *   * @param e the key event to dispatch.   * @return true if the event was dispatched successfully.   */  public abstract boolean dispatchKeyEvent (KeyEvent e);  /**   * Handles the post processing of key events.  By default,   * this method will map unhandled key events to appropriate   * <code>MenuShortcut</code>s.  The event is consumed   * in the process and the shortcut is activated.  This   * method is usually called by <code>dispatchKeyEvent</code>.   *   * @param e the key event to post process.   * @return true by default, as the event was handled.   */  public abstract boolean postProcessKeyEvent (KeyEvent e);  /**   * Handles focus traversal operations for key events which   * represent focus traversal keys in relation to the supplied   * component.  The supplied component is assumed to have the   * focus, whether it does so or not, and the operation is   * carried out as appropriate, with this in mind.   *   * @param focused the component on which to perform focus traversal,   *        on the assumption that this component has the focus.   * @param e the possible focus traversal key event.   */  public abstract void processKeyEvent (Component focused, KeyEvent e);  /**   * Delays all key events following the specified timestamp until the   * supplied component has focus.  The AWT calls this method when it is   * determined that a focus change may occur within the native windowing   * system.  Any key events which occur following the time specified by   * after are delayed until a <code>FOCUS_GAINED</code> event is received   * for the untilFocused component.  The manager is responsible for ensuring   * this takes place.   *   * @param after the timestamp beyond which all key events are delayed until   *        the supplied component gains focus.   * @param untilFocused the component to wait on gaining focus.   */  protected abstract void enqueueKeyEvents (long after, Component untilFocused);  /**   * Removes the key event block specified by the supplied timestamp and component.   * All delayed key events are released for normal dispatching following its   * removal and subsequent key events that would have been blocked are now   * immediately dispatched.  If the specified timestamp is below 0, then   * the request with the oldest timestamp is removed.   *   * @param after the timestamp of the key event block to be removed, or a   *        value smaller than 0 if the oldest is to be removed.   * @param untilFocused the component of the key event block to be removed.   */  protected abstract void dequeueKeyEvents (long after, Component untilFocused);  /**   * Discards all key event blocks relating to focus requirements for   * the supplied component, regardless of timestamp.   *   * @param comp the component of the key event block(s) to be removed.   */  protected abstract void discardKeyEvents (Component comp);  /**   * Moves the current focus to the next component following   * comp, based on the current focus traversal policy.  By   * default, only visible, displayable, accepted components   * can receive focus.  <code>Canvas</code>es, <code>Panel</code>s,   * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,   * <code>Window</code>s and lightweight components are judged   * to be unacceptable by default.  See the   * <code>DefaultFocusTraversalPolicy</code> for more details.   *   * @param comp the component prior to the one which will   *        become the focus, following execution of this method.   * @see DefaultFocusTraversalPolicy   */  public abstract void focusNextComponent(Component comp);  /**   * Moves the current focus to the previous component, prior to   * comp, based on the current focus traversal policy.  By   * default, only visible, displayable, accepted components   * can receive focus.  <code>Canvas</code>es, <code>Panel</code>s,   * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,   * <code>Window</code>s and lightweight components are judged   * to be unacceptable by default.  See the   * <code>DefaultFocusTraversalPolicy</code> for more details.   *   * @param comp the component following the one which will   *        become the focus, following execution of this method.   * @see DefaultFocusTraversalPolicy   */  public abstract void focusPreviousComponent(Component comp);  /**   * Moves the current focus upwards by one focus cycle.   * Both the current focus owner and current focus cycle root   * become the focus cycle root of the supplied component.   * However, in the case of a <code>Window</code>, the default   * focus component becomes the focus owner and the focus cycle   * root is not changed.   *    * @param comp the component used as part of the focus traversal.   */   public abstract void upFocusCycle(Component comp);  /**   * Moves the current focus downwards by one focus cycle.   * If the supplied container is a focus cycle root, then this   * becomes the current focus cycle root and the focus goes   * to the default component of the specified container.   * Nothing happens for non-focus cycle root containers.    *    * @param cont the container used as part of the focus traversal.   */   public abstract void downFocusCycle(Container cont);  /**   * Moves the current focus to the next component, based on the   * current focus traversal policy.  By default, only visible,   * displayable, accepted component can receive focus.   * <code>Canvas</code>es, <code>Panel</code>s,   * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,   * <code>Window</code>s and lightweight components are judged   * to be unacceptable by default.  See the   * <code>DefaultFocusTraversalPolicy</code> for more details.   *   * @see DefaultFocusTraversalPolicy   */  public final void focusNextComponent()  {    focusNextComponent (null);  }  /**   * Moves the current focus to the previous component, based on the   * current focus traversal policy.  By default, only visible,   * displayable, accepted component can receive focus.   * <code>Canvas</code>es, <code>Panel</code>s,   * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,   * <code>Window</code>s and lightweight components are judged   * to be unacceptable by default.  See the   * <code>DefaultFocusTraversalPolicy</code> for more details.   *   * @see DefaultFocusTraversalPolicy   */  public final void focusPreviousComponent()  {    focusPreviousComponent (null);  }  /**   * Moves the current focus upwards by one focus cycle,   * so that the new focus owner is the focus cycle root   * of the current owner.  The current focus cycle root then   * becomes the focus cycle root of the new focus owner.   * However, in the case of the focus cycle root of the   * current focus owner being a <code>Window</code>, the default   * component of this window becomes the focus owner and the   * focus cycle root is not changed.   */  public final void upFocusCycle()  {    upFocusCycle (null);  }  /**   * Moves the current focus downwards by one focus cycle,   * iff the current focus cycle root is a <code>Container</code>.   * Usually, the new focus owner is set to the default component   * of the container and the current focus cycle root is set   * to the current focus owner.  Nothing occurs if the current   * focus cycle root is not a container.   */  public final void downFocusCycle()  {    Component focusOwner = getGlobalFocusOwner ();    if (focusOwner instanceof Container        && ((Container) focusOwner).isFocusCycleRoot ())      downFocusCycle ((Container) focusOwner);  }  /**   * Retrieve an object from one of the global object {@link   * java.util.Map}s, if the object was set by the a thread in the   * current {@link java.lang.ThreadGroup}.  Otherwise, return null.   *   * @param globalMap one of the global object Maps   *   * @return a global object set by the current ThreadGroup, or null   *   * @see #getFocusOwner()   * @see #getPermanentFocusOwner()   * @see #getFocusedWindow()   * @see #getActiveWindow()   * @see #getCurrentFocusCycleRoot()   */  private Object getObject (Map globalMap)  {    ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();    return globalMap.get (currentGroup);  }  /**   * Retrieve an object from one of the global object {@link   * java.util.Map}s, regardless of whether or not the object was set   * by a thread in the current {@link java.lang.ThreadGroup}.   *   * @param globalMap one of the global object Maps   *   * @return a global object set by the current ThreadGroup, or null   *   * @throws SecurityException if this is not the keyboard focus   * manager associated with the current {@link java.lang.ThreadGroup}   *   * @see #getGlobalFocusOwner()   * @see #getGlobalPermanentFocusOwner()   * @see #getGlobalFocusedWindow()   * @see #getGlobalActiveWindow()   * @see #getGlobalCurrentFocusCycleRoot()   */  private Object getGlobalObject (Map globalMap)  {    ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();    KeyboardFocusManager managerForCallingThread      = (KeyboardFocusManager) currentKeyboardFocusManagers.get (currentGroup);    if (this != managerForCallingThread)      throw new SecurityException ("Attempted to retrieve an object from a "                                   + "keyboard focus manager that isn't "                                   + "associated with the current thread group.");    synchronized (globalMap)      {        Collection globalObjects = globalMap.values ();        Iterator i = globalObjects.iterator ();        Component globalObject;        while (i.hasNext ())          {            globalObject = (Component) i.next ();            if (globalObject != null)              return globalObject;          }      }    // No Object was found.    return null;  }  /**   * Set an object in one of the global object {@link java.util.Map}s,   * that will be returned by subsequent calls to getGlobalObject on   * the same {@link java.util.Map}.   *   * @param globalMap one of the global object Maps   * @param newObject the object to set   * @param property the property that will change   *   * @see #setGlobalFocusOwner(Component)   * @see #setGlobalPermanentFocusOwner(Component)   * @see #setGlobalFocusedWindow(Window)   * @see #setGlobalActiveWindow(Window)   * @see #setGlobalCurrentFocusCycleRoot(Container)   */  private void setGlobalObject (Map globalMap,                                Object newObject,                                String property)  {    synchronized (globalMap)      {        // Save old object.        Object oldObject = getGlobalObject (globalMap);        // Nullify old object.        Collection threadGroups = globalMap.keySet ();        Iterator i = threadGroups.iterator ();        while (i.hasNext ())          {            ThreadGroup oldThreadGroup = (ThreadGroup) i.next ();            if (globalMap.get (oldThreadGroup) != null)              {                globalMap.put (oldThreadGroup, null);                // There should only be one object set at a time, so                // we can short circuit.                break;              }          }        ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();        firePropertyChange (property, oldObject, newObject);        try          {            fireVetoableChange (property, oldObject, newObject);            // Set new object.            globalMap.put (currentGroup, newObject);          }        catch (PropertyVetoException e)          {          }      }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -