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

📄 component.java

📁 java virtual machince kaffe
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		if ( linkedGraphs != null )			updateLinkedGraphics();	}}public boolean imageUpdate (Image img, int infoflags, int x, int y, int width, int height ) {	if ( (infoflags & (ALLBITS | FRAMEBITS)) != 0 ) {		if ( (flags & IS_SHOWING) == IS_SHOWING )			repaint();	}	// We return false if we're no longer interested in updates.This is *NOT*	// what is said in the Addison-Wesley documentation, but is what is says	// in the JDK javadoc documentation.	if ( (infoflags & (ALLBITS | ABORT | ERROR)) != 0 ) {		return (false);	}	else {		return (true);	}}/** * @deprecated */public boolean inside ( int x, int y ) {	if ( (flags & IS_SHOWING) != IS_SHOWING ) return false;	if ( (x < 0) || (y < 0) || (x > width) || (y > height) ) return false;/***	// If we want to deal with components being bigger than their parents,	// we have to check for parent.contains(), too. However, this is not	// done by the JDK, and we therefor skip it for now	x += this.x; y += this.y;	for ( Container c=parent; c!= null; x += c.x, y += c.y, c = c.parent ) {		if ( (x < 0) || (y < 0) || (x > c.width) || (y > c.height) )			return false;	}***/	return true;}boolean intersects ( Component c ) {	return intersects( c.x, c.y, c.width, c.height);}boolean intersects ( Rectangle r ) {	return intersects( r.x, r.y, r.width, r.height);}boolean intersects ( int u, int v, int w, int h ) {	if ( (x > (u + w))  ||	     (y > (v + h)) ||	     (u > (x + width))    ||	     (v > (y + height)) )		return false;	else		return true;}public void invalidate () {	// invalidation means invalid yourself *and* all your parents (if they	// arent't already)	synchronized ( treeLock ) {		if ( (flags & IS_VALID) != 0 ) {			flags &= ~IS_VALID;					// maybe, it's overloaded (we have to sacrifice speed for compat, here)			// parent can't be null, because we can't get valid without being addNotifyed			if ( (parent.flags & IS_VALID) != 0 )				parent.invalidate();		}	}}/** * PersonalJava 1.1 method */public boolean isDoubleBuffered() {	return (false);}public boolean isEnabled () {	return (eventMask & AWTEvent.DISABLED_MASK) == 0;}public boolean isFocusTraversable() {	return (((flags & (IS_SHOWING|IS_NATIVE_LIKE)) == (IS_SHOWING|IS_NATIVE_LIKE)) && 	        ((eventMask & AWTEvent.DISABLED_MASK) == 0));}/*** Tests if this component can receive focus. * * @return true if this component can receive focus * @since 1.4 */public boolean isFocusable(){    return focusable;}/*** Specify whether this component can receive focus. This method also * sets the {@link #isFocusTraversableOverridden} field to 1, which * appears to be the undocumented way {@link     * DefaultFocusTraversalPolicy#accept(Component)} determines whether to * respect the {@link #isFocusable()} method of the component. * * @param focusable the new focusable status * @since 1.4 */public void setFocusable(boolean focusable){    firePropertyChange("focusable", this.focusable, focusable);    this.focusable = focusable;    this.isFocusTraversableOverridden = 1;}  /**   * Sets the focus traversal keys for one of the three focus   * traversal directions supported by Components:   * {@link KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS},   * {@link KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS}, or   * {@link KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS}. Normally, the   * default values should match the operating system's native   * choices. To disable a given traversal, use   * <code>Collections.EMPTY_SET</code>. The event dispatcher will   * consume PRESSED, RELEASED, and TYPED events for the specified   * key, although focus can only transfer on PRESSED or RELEASED.   *   * <p>The defaults are:   * <table>   *   <th><td>Identifier</td><td>Meaning</td><td>Default</td></th>   *   <tr><td>KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS</td>   *     <td>Normal forward traversal</td>   *     <td>TAB on KEY_PRESSED, Ctrl-TAB on KEY_PRESSED</td></tr>   *   <tr><td>KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS</td>   *     <td>Normal backward traversal</td>   *     <td>Shift-TAB on KEY_PRESSED, Ctrl-Shift-TAB on KEY_PRESSED</td></tr>   *   <tr><td>KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS</td>   *     <td>Go up a traversal cycle</td><td>None</td></tr>   * </table>   *   * If keystrokes is null, this component's focus traversal key set   * is inherited from one of its ancestors.  If none of its ancestors   * has its own set of focus traversal keys, the focus traversal keys   * are set to the defaults retrieved from the current   * KeyboardFocusManager.  If not null, the set must contain only   * AWTKeyStrokes that are not already focus keys and are not   * KEY_TYPED events.   *   * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or   *        UP_CYCLE_TRAVERSAL_KEYS   * @param keystrokes a set of keys, or null   * @throws IllegalArgumentException if id or keystrokes is invalid   * @see #getFocusTraversalKeys(int)   * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS   * @since 1.4   */  public void setFocusTraversalKeys(int id, Set keystrokes)  {    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;    String name;    switch (id)      {      case KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);        name = "forwardFocusTraversalKeys";        break;      case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);        name = "backwardFocusTraversalKeys";        break;      case KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS:        sa = getFocusTraversalKeys          (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);        sb = getFocusTraversalKeys          (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);        name = "upCycleFocusTraversalKeys";        break;      default:        throw new IllegalArgumentException ();      }    int i = keystrokes.size ();    Iterator iter = keystrokes.iterator ();    while (--i >= 0)      {        Object o = iter.next ();        if (!(o instanceof AWTKeyStroke)            || sa.contains (o) || sb.contains (o)            || ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)          throw new IllegalArgumentException ();      }    if (focusTraversalKeys == null)      focusTraversalKeys = new Set[3];    keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));    firePropertyChange (name, focusTraversalKeys[id], keystrokes);    focusTraversalKeys[id] = keystrokes;  }  /**   * Returns the set of keys for a given focus traversal action, as   * defined in <code>setFocusTraversalKeys</code>.  If not set, this   * is inherited from the parent component, which may have gotten it   * from the KeyboardFocusManager.   *   * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,   * or UP_CYCLE_TRAVERSAL_KEYS   *   * @return set of traversal keys   *   * @throws IllegalArgumentException if id is invalid   *    * @see #setFocusTraversalKeys (int, Set)   * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS   *    * @since 1.4   */  public Set getFocusTraversalKeys (int id)  {    if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)      throw new IllegalArgumentException();    Set s = null;    if (focusTraversalKeys != null)      s = focusTraversalKeys[id];    if (s == null && parent != null)      s = parent.getFocusTraversalKeys (id);    return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()                        .getDefaultFocusTraversalKeys(id)) : s;  }  /**   * Tests whether the focus traversal keys for a given action are explicitly   * set or inherited.   *   * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,   * or UP_CYCLE_TRAVERSAL_KEYS   * @return true if that set is explicitly specified   * @throws IllegalArgumentException if id is invalid   * @see #getFocusTraversalKeys (int)   * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS   * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS   * @since 1.4   */  public boolean areFocusTraversalKeysSet (int id)  {    if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&        id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)      throw new IllegalArgumentException ();    return focusTraversalKeys != null && focusTraversalKeys[id] != null;  }  /**   * Enable or disable focus traversal keys on this Component.  If   * they are, then the keyboard focus manager consumes and acts on   * key press and release events that trigger focus traversal, and   * discards the corresponding key typed events.  If focus traversal   * keys are disabled, then all key events that would otherwise   * trigger focus traversal are sent to this Component.   *   * @param focusTraversalKeysEnabled the new value of the flag   * @see #getFocusTraversalKeysEnabled ()   * @see #setFocusTraversalKeys (int, Set)   * @see #getFocusTraversalKeys (int)   * @since 1.4   */  public void setFocusTraversalKeysEnabled (boolean focusTraversalKeysEnabled)  {    firePropertyChange ("focusTraversalKeysEnabled",			this.focusTraversalKeysEnabled,			focusTraversalKeysEnabled);    this.focusTraversalKeysEnabled = focusTraversalKeysEnabled;  }  /**   * Check whether or not focus traversal keys are enabled on this   * Component.  If they are, then the keyboard focus manager consumes   * and acts on key press and release events that trigger focus   * traversal, and discards the corresponding key typed events.  If   * focus traversal keys are disabled, then all key events that would   * otherwise trigger focus traversal are sent to this Component.   *   * @return true if focus traversal keys are enabled   * @see #setFocusTraversalKeysEnabled (boolean)   * @see #setFocusTraversalKeys (int, Set)   * @see #getFocusTraversalKeys (int)   * @since 1.4   */  public boolean getFocusTraversalKeysEnabled ()  {    return focusTraversalKeysEnabled;  }/*** Tests if this component is the focus owner. Use {@link    * #isFocusOwner ()} instead. * * @return true if this component owns focus * @since 1.2 */public boolean hasFocus (){    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();    Component focusOwner = manager.getFocusOwner ();    return this == focusOwner;}/*** Tests if this component is the focus owner. * * @return true if this component owns focus * @since 1.4 */public boolean isFocusOwner(){    return hasFocus ();}public boolean isShowing () {	// compare the costs of this with the standard upward iteration return  ((flags & (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED)) ==	                 (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED));}public boolean isValid () {	return ((flags & IS_VALID) != 0);}public boolean isVisible () {	return ((flags & IS_VISIBLE) != 0);}/*** Tests if the component is displayable. It must be connected to a native * screen resource.  This reduces to checking that peer is not null.  A * containment  hierarchy is made displayable when a window is packed or * made visible. * * @return true if the component is displayable * @see Container#add(Component) * @see Container#remove(Component) * @see Window#pack() * @see Window#show() * @see Window#dispose() * @since 1.2 */public boolean isDisplayable(){    // since we are peerless...    return true;//    return peer != null;}/** * @deprecated */public boolean keyDown(Event evt, int key) {	return (false);}/** * @deprecated */public boolean keyUp(Event evt, int key) {	return (false);}/** * @deprecated, use doLayout() */public void layout() {}synchronized void linkGraphics ( NativeGraphics g ) {	GraphicsLink li, last, next; 	// do some cleanup as we go	for ( li = linkedGraphs, last = null; li != null; ){		if ( li.get() == null ){			// recycle this one, its Graphics has been collected			if ( last == null ){				linkedGraphs = li.next;			}			else {				last.next = li.next;			}						next = li.next;			li = next;		}		else {			last = li;			li = li.next;		}	}		// References are immutable, i.e. we can't cache them for later re-use.	// Since we cache Graphics objects, the best we can do is to use GraphicsLinks	// objects exclusively (sort of per-Gra

⌨️ 快捷键说明

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