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

📄 container.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   */  public synchronized void addContainerListener(ContainerListener listener)  {    containerListener = AWTEventMulticaster.add(containerListener, listener);  }  /**   * Removes the specified container listener from this object's list of   * container listeners.   *   * @param listener The listener to remove.   */  public synchronized void removeContainerListener(ContainerListener listener)  {    containerListener = AWTEventMulticaster.remove(containerListener, listener);  }  /**   * @since 1.4   */  public synchronized ContainerListener[] getContainerListeners()  {    return (ContainerListener[])      AWTEventMulticaster.getListeners(containerListener,                                       ContainerListener.class);  }  /**   * Returns an array of all the objects currently registered as FooListeners   * upon this Container. FooListeners are registered using the addFooListener   * method.   *   * @exception ClassCastException If listenerType doesn't specify a class or   * interface that implements @see java.util.EventListener.   *   * @since 1.3   */  public EventListener[] getListeners(Class listenerType)  {    if (listenerType == ContainerListener.class)      return getContainerListeners();    return super.getListeners(listenerType);  }  /**   * Processes the specified event.  This method calls   * <code>processContainerEvent()</code> if this method is a   * <code>ContainerEvent</code>, otherwise it calls the superclass   * method.   *   * @param e The event to be processed.   */  protected void processEvent(AWTEvent e)  {    if (e instanceof ContainerEvent)      processContainerEvent((ContainerEvent) e);    else      super.processEvent(e);  }  /**   * Called when a container event occurs if container events are enabled.   * This method calls any registered listeners.   *   * @param e The event that occurred.   */  protected void processContainerEvent(ContainerEvent e)  {    if (containerListener == null)      return;    switch (e.id)      {      case ContainerEvent.COMPONENT_ADDED:        containerListener.componentAdded(e);        break;      case ContainerEvent.COMPONENT_REMOVED:        containerListener.componentRemoved(e);        break;      }  }  /**   * AWT 1.0 event processor.   *   * @param e The event that occurred.   *   * @deprecated use {@link #dispatchEvent(AWTEvent)} instead   */  public void deliverEvent(Event e)  {    if (!handleEvent (e))      {        synchronized (getTreeLock ())          {            Component parent = getParent ();            if (parent != null)              parent.deliverEvent (e);          }      }  }  /**   * Returns the component located at the specified point.  This is done   * by checking whether or not a child component claims to contain this   * point.  The first child component that does is returned.  If no   * child component claims the point, the container itself is returned,   * unless the point does not exist within this container, in which   * case <code>null</code> is returned.   *   * @param x The X coordinate of the point.   * @param y The Y coordinate of the point.   *   * @return The component containing the specified point, or   * <code>null</code> if there is no such point.   */  public Component getComponentAt(int x, int y)  {    return locate (x, y);  }  /**   * Returns the component located at the specified point.  This is done   * by checking whether or not a child component claims to contain this   * point.  The first child component that does is returned.  If no   * child component claims the point, the container itself is returned,   * unless the point does not exist within this container, in which   * case <code>null</code> is returned.   *   * @param x The x position of the point to return the component at.   * @param y The y position of the point to return the component at.   *   * @return The component containing the specified point, or <code>null</code>   * if there is no such point.   *   * @deprecated use {@link #getComponentAt(int, int)} instead   */  public Component locate(int x, int y)  {    synchronized (getTreeLock ())      {        if (!contains (x, y))          return null;        for (int i = 0; i < ncomponents; ++i)          {            // Ignore invisible children...            if (!component[i].isVisible ())              continue;            int x2 = x - component[i].x;            int y2 = y - component[i].y;            if (component[i].contains (x2, y2))              return component[i];          }        return this;      }  }  /**   * Returns the component located at the specified point.  This is done   * by checking whether or not a child component claims to contain this   * point.  The first child component that does is returned.  If no   * child component claims the point, the container itself is returned,   * unless the point does not exist within this container, in which   * case <code>null</code> is returned.   *   * @param p The point to return the component at.   * @return The component containing the specified point, or <code>null</code>   * if there is no such point.   */  public Component getComponentAt(Point p)  {    return getComponentAt (p.x, p.y);  }  public Component findComponentAt(int x, int y)  {    synchronized (getTreeLock ())      {        if (! contains(x, y))          return null;        for (int i = 0; i < ncomponents; ++i)          {            // Ignore invisible children...            if (!component[i].isVisible())              continue;            int x2 = x - component[i].x;            int y2 = y - component[i].y;            // We don't do the contains() check right away because            // findComponentAt would redundantly do it first thing.            if (component[i] instanceof Container)              {                Container k = (Container) component[i];                Component r = k.findComponentAt(x2, y2);                if (r != null)                  return r;              }            else if (component[i].contains(x2, y2))              return component[i];          }        return this;      }  }    /**   * Finds the visible child component that contains the specified position.   * The top-most child is returned in the case where there is overlap.   * If the top-most child is transparent and has no MouseListeners attached,   * we discard it and return the next top-most component containing the   * specified position.   * @param x the x coordinate   * @param y the y coordinate   * @return null if the <code>this</code> does not contain the position,   * otherwise the top-most component (out of this container itself and    * its descendants) meeting the criteria above.   */  Component findComponentForMouseEventAt(int x, int y)  {    synchronized (getTreeLock())      {        if (!contains(x, y))          return null;        for (int i = 0; i < ncomponents; ++i)          {            // Ignore invisible children...            if (!component[i].isVisible())              continue;            int x2 = x - component[i].x;            int y2 = y - component[i].y;            // We don't do the contains() check right away because            // findComponentAt would redundantly do it first thing.            if (component[i] instanceof Container)              {                Container k = (Container) component[i];                Component r = k.findComponentForMouseEventAt(x2, y2);                if (r != null)                  return r;              }            else if (component[i].contains(x2, y2))              return component[i];          }        //don't return transparent components with no MouseListeners        if (this.getMouseListeners().length == 0)          return null;        return this;      }  }  public Component findComponentAt(Point p)  {    return findComponentAt(p.x, p.y);  }  /**   * Called when this container is added to another container to inform it   * to create its peer.  Peers for any child components will also be   * created.   */  public void addNotify()  {    super.addNotify();    addNotifyContainerChildren();  }  /**   * Called when this container is removed from its parent container to   * inform it to destroy its peer.  This causes the peers of all child   * component to be destroyed as well.   */  public void removeNotify()  {    synchronized (getTreeLock ())      {        for (int i = 0; i < ncomponents; ++i)          component[i].removeNotify();        super.removeNotify();      }  }  /**   * Tests whether or not the specified component is contained within   * this components subtree.   *   * @param comp The component to test.   *   * @return <code>true</code> if this container is an ancestor of the   * specified component, <code>false</code> otherwise.   */  public boolean isAncestorOf(Component comp)  {    synchronized (getTreeLock ())      {        while (true)          {            if (comp == null)              return false;            if (comp == this)              return true;            comp = comp.getParent();          }      }  }  /**   * Returns a string representing the state of this container for   * debugging purposes.   *   * @return A string representing the state of this container.   */  protected String paramString()  {    if (layoutMgr == null)      return super.paramString();    StringBuffer sb = new StringBuffer();    sb.append(super.paramString());    sb.append(",layout=");    sb.append(layoutMgr.getClass().getName());    return sb.toString();  }  /**   * Writes a listing of this container to the specified stream starting   * at the specified indentation point.   *   * @param out The <code>PrintStream</code> to write to.   * @param indent The indentation point.   */  public void list(PrintStream out, int indent)  {    synchronized (getTreeLock ())      {        super.list(out, indent);        for (int i = 0; i < ncomponents; ++i)          component[i].list(out, indent + 2);      }  }  /**   * Writes a listing of this container to the specified stream starting   * at the specified indentation point.   *   * @param out The <code>PrintWriter</code> to write to.   * @param indent The indentation point.   */  public void list(PrintWriter out, int indent)  {    synchronized (getTreeLock ())      {        super.list(out, indent);        for (int i = 0; i < ncomponents; ++i)          component[i].list(out, indent + 2);      }  }  /**   * Sets the focus traversal keys for a given traversal operation for this   * Container.   *   * @exception IllegalArgumentException If id is not one of   * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,   * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,   * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS,   * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS,   * or if keystrokes contains null, or if any Object in keystrokes is not an   * AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any   * keystroke already maps to another focus traversal operation for this   * Container.   *   * @since 1.4   */  public void setFocusTraversalKeys(int id, Set keystrokes)  {    if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)      throw new IllegalArgumentException ();    if (keystrokes == null)      {        Container parent = getParent ();        while (parent != null)          {            if (parent.areFocusTraversalKeysSet (id))              {                keystrokes = parent.getFocusTraversalKeys (id);                break;              }            parent = parent.getParent ();          }        if (keystrokes == null)          keystrokes = KeyboardFocusManager.getCurrentKeyboardFocusManager ().            getDefaultFocusTraversalKeys (id);      }    Set sa;    Set sb;    Set sc;    String name;    switch (id)      {      case KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);        sc = getFocusTraversalKeys          (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);        name = "forwardFocusTraversalKeys";        break;      case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);        sc = getFocusTraversalKeys          (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);        name = "backwardFocusTraversalKeys";        break;      case KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);        sc = getFocusTraversalKeys

⌨️ 快捷键说明

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