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

📄 component.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	if ( this == AWTEvent.mouseTgt )		AWTEvent.mouseTgt = null;	if ( this == AWTEvent.keyTgt )		AWTEvent.keyTgt = null;	if ( this == AWTEvent.activeWindow )		AWTEvent.activeWindow = null;	if ( this == FocusEvt.keyTgtRequest )		FocusEvt.keyTgtRequest = null;		// this is arguable - we could also make the check in all relevant event dipatch()	// methods, but it's probably more efficient to do it once, at the source	// (note that we don't have to care for native events because of unregisterSource())	if ( Toolkit.eventQueue.localQueue != null ) {		Toolkit.eventQueue.dropLiveEvents( this);	}}public void repaint () {	repaint( 0, 0, 0, width, height);}public void repaint ( int x, int y, int width, int height ) {	repaint( 0, x, y, width, height);}public void repaint ( long ms ) {	repaint( ms, 0, 0, width, height);}public void repaint ( long ms, int x, int y, int width, int height ) {	if ( (flags & IS_SHOWING) == IS_SHOWING ){			// be paranoid, some clients might request repaints outside their own turf		if ( x < 0 ) x = 0;		if ( y < 0 ) y = 0;		if ( (x + width) > this.width )			width = this.width - x;		if ( (y + height) > this.height )			height = this.height - y;			Toolkit.eventQueue.postPaintEvent( PaintEvent.UPDATE, this, x, y, width, height);	}}public void requestFocus () {	Component topNew;	if ( AWTEvent.keyTgt == this ){   // nothing to do		return;	}	topNew = getToplevel();		// there are bad apps out there requesting the focus for Components	// which have not even been addNotified yet (hence no parent)	if ( topNew == null ) {		// most native AWTs will fail here, but with our mechanism, we		// can try harder: store request in the hope it will be honored		// by a subsequent requestFocus of the toplevel		FocusEvt.keyTgtRequest = this;	}	else {		if (topNew != AWTEvent.activeWindow ) {  // this involves a change of active toplevels			FocusEvt.keyTgtRequest = this;			topNew.requestFocus();		}		else {                                 // intra toplevel focus change			Toolkit.eventQueue.postFocusEvent( FocusEvt.getEvent( this, FocusEvent.FOCUS_GAINED, false));		}	}}/** * @deprecated, use setBounds(x,y,w,h) * this is never called automatically, override setBounds in derived classes * to change the default behavior */public void reshape ( int xNew, int yNew, int wNew, int hNew ) {	// DEP - this should be in setBounds !! But we have to keep it here	// for compatibility reasons (Swing etc.)	int      x0=0, x1=0, y0=0, y1=0, a, b;	boolean  sized = ( (width != wNew) || (height != hNew) );	boolean  moved = ( !sized && ((x != xNew) || (y != yNew)) );	int      id = sized ? ComponentEvent.COMPONENT_RESIZED : ComponentEvent.COMPONENT_MOVED;	// Don't do anything if we don't change anything.	if (sized || moved) {		if ( parent != null ) {			// Strange, but happens (e.g. for Swing InternalFrames): somebody			// explicitly moved the mouseTgt or one of its parents (maybe in a mouse modal drag!)			if ( MouseEvt.mouseDragged ) {				for ( Component c=AWTEvent.mouseTgt; c!= null; c=c.parent ){					if ( c == this ) {						MouseEvt.moveMouseTgt( (xNew - x), (yNew - y));						break;					}				}			}			if ( (flags & IS_SHOWING) == IS_SHOWING ) {				x0 = (xNew < x) ? xNew : x;				y0 = (yNew < y) ? yNew : y;				a = xNew + wNew;				b = x + width;				x1 = (a > b ? a : b);				a = yNew + hNew;				b = y + height;				y1 = (a > b ? a : b);							x = xNew; y = yNew; width = wNew; height = hNew;				invalidate();								if ( (cmpListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ){					Toolkit.eventQueue.postEvent( ComponentEvt.getEvent( this, id));				}				propagateReshape();				// Redrawing the parent does not happen automatically, we can do it here				// (regardless of IS_LAYOUTING) since we have repaint - solicitation, anyway				parent.repaint( x0, y0, (x1-x0), (y1-y0));				return;			}		}		x = xNew; y = yNew; width = wNew; height = hNew;		invalidate();		if ( (cmpListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ){			Toolkit.eventQueue.postEvent( ComponentEvt.getEvent( this, id));		}		propagateReshape();	}}/** * @deprecated, use setSize( d) * this is never called automatically, override setSize in derived classes * to change the default behavior */public void resize ( Dimension d ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	setSize( d.width, d.height);}/** * @deprecated, use setSize(w,h) * this is never called automatically, override setSize in derived classes * to change the default behavior */public void resize ( int wNew, int hNew ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	setBounds( x, y, wNew, hNew);}public void setBackground ( Color clr ) {	if ( clr == bgClr )		return;	if ( clr != null ){		flags |= IS_BG_COLORED;	}	else {		flags &= ~IS_BG_COLORED;		if ( parent != null )			clr = parent.bgClr;	}	propagateBgClr( clr);	// we follow the "Java class libraries" description here (in favor of the Sun class docu), i.e.	// clients have to explicitly force a repaint after changing colors. But - since many apps	// rely in this unspec. behavior - we have to repaint automatically for native-likes	if ( (flags & (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED | IS_NATIVE_LIKE))	        == (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED) ) {		repaint();	}}public void setBounds ( Rectangle r ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	setBounds( r.x, r.y, r.width, r.height);}public void setBounds ( int xNew, int yNew, int wNew, int hNew ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	reshape( xNew, yNew, wNew, hNew );}public void setCursor ( Cursor newCursor ) {	Component c;	cursor = newCursor;		// go native, but don't change toplevels cursor field	for ( c = this; c.parent != null; c = c.parent );	c.setNativeCursor( cursor);}public void setEnabled ( boolean isEnabled ) {	if ( isEnabled)		eventMask &= ~AWTEvent.DISABLED_MASK;	else		eventMask |= AWTEvent.DISABLED_MASK;			checkMouseAware();}public void setFont ( Font fnt ) {	if ( fnt == font )		return;	if ( fnt != null ){		flags |= IS_FONTIFIED;	}	else {		flags &= ~IS_FONTIFIED;		if ( parent != null )			fnt = parent.font;	}	propagateFont( fnt);	// see setBackground for further details about why to repaint just visible native-likes	if ( (flags & (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED | IS_NATIVE_LIKE))	        == (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED) ) {		repaint();	}}public void setForeground ( Color clr ) {	if ( clr == fgClr )		return;	if ( clr != null ){		flags |= IS_FG_COLORED;	}	else {		flags &= ~IS_FG_COLORED;		if ( parent != null )			clr = parent.fgClr;	}	propagateFgClr( clr);	// see setBackground for further details about why to repaint just visible native-likes	if ( (flags & (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED | IS_NATIVE_LIKE))	        == (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED) ) {		repaint();	}}public void setLocale(Locale loc) {	locale = loc;}public void setLocation ( Point pt ) {	setLocation( pt.x, pt.y );}public void setLocation ( int x, int y ) {	move( x, y);}public void setName ( String newName ) {	name = newName;}void setNativeCursor ( Cursor cursor ) {}public void setSize ( Dimension dim ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	resize( dim);}public void setSize ( int newWidth, int newHeight ) {	// Part of the JDK resize/setSize/setBounds/reshape twist. Don't change or you	// might break compatibility of derived app classes. The workhorse is still reshape	resize( newWidth, newHeight);}public void setVisible ( boolean b ) {	show( b);}public void show () {	// DEP this should be in setVisible !! But we have to keep it here	// for compatibility reasons (Swing etc.)	if ( (flags & IS_VISIBLE) == 0 ) {		flags |= IS_VISIBLE;		flags &= ~IS_TEMP_HIDDEN;	  // if we are a toplevel, the native window manager will take care	  // of repainting		if ( (parent != null) && ((parent.flags & IS_LAYOUTING) == 0) ) {			if ( (flags & (IS_ADD_NOTIFIED | IS_PARENT_SHOWING))			       == (IS_ADD_NOTIFIED | IS_PARENT_SHOWING) ){			  //parent.repaint( x, y, width, height);				repaint();			}						if ( (parent.flags & IS_VALID) != 0 )				parent.invalidate();		}		if ( (cmpListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ){			Toolkit.eventQueue.postEvent( ComponentEvt.getEvent( this,				                                    ComponentEvent.COMPONENT_SHOWN));		}		// update any resident graphics objects				if ( linkedGraphs != null )			updateLinkedGraphics();	}}public void show ( boolean b ) {	// DEP this should map to setVisible but we have to keep it that way because of	// compatibility, which in this case requires a double indirection)	if ( b)		show();	else		hide();}/** * @deprecated, use getSize() */public Dimension size () {	// DEP - should be in getSize() (but can't because of JDK compatibility)	// We have to return fresh objects because of the same reasons like in bounds()	return new Dimension( width, height);}public String toString () {	return (getClass().getName() + '[' + paramString() + ']');}/** * Transfer the focus to the next appropriate components in this * components container. */public void transferFocus() {	Component curr = this;	while (curr.parent != null) {		Container parent = curr.parent;		int end = parent.getComponentCount();		/* Find out where 'curr' is in its container so we can start		 * looking for the next component after it		 */		int start;		for (start = 0; start < end; start++) {			Component c = parent.getComponent(start);			if (c == curr) {				break;			}		}		/* This shouldn't happen but just in case ... */		if (start == end) {			return;		}		/* Look for next focusable component after me */		for (start++; start < end; start++) {			Component c = parent.getComponent(start);			if (c.isEnabled() && ((c.flags & IS_VISIBLE) !=0) && c.isFocusTraversable()) {			  // Then if it is enabled, visible and focus traversable set the focus to it			  c.requestFocus();			  return;			} else if (c instanceof Container) {			  // If it is a container drop into it			parent = (Container)c;			end = parent.getComponentCount();			start = -1;			}		}		curr = parent;	}}PopupMenu triggerPopup ( int x, int y ) {	if ( popup != null ) {		popup.show( this, x, y);		return popup;	}		return null;}synchronized void unlinkGraphics ( NativeGraphics g ) {	GraphicsLink li, last, next;	Object       lg;	// do some cleanup as we go	for ( li = linkedGraphs, last = null; li != null; ){		if ( ((lg = li.get()) == null) || (lg == g ) ){			// recycle this one, its Graphics has been collected or disposed			if ( last == null ){				linkedGraphs = li.next;			}			else {				last.next = li.next;			}						next = li.next;			li = next;		}		else {			last = li;			li = li.next;		}	}}public void update ( Graphics g ) {	g.clearRect( 0, 0, width, height);	paint( g);}// TODO this is only a stubpublic ComponentOrientation getComponentOrientation() {	return ComponentOrientation.LEFT_TO_RIGHT;}// TODO this is only a stubpublic void applyComponentOrientation(ComponentOrientation orientation) {}// TODO this is only a stubpublic void addMouseWheelListener(MouseWheelListener l) {}synchronized void updateLinkedGraphics () {	GraphicsLink li, last, next;	for ( li = linkedGraphs, last = null; li != null; ){		if ( !li.updateGraphics( this) ){			// recycle this one on-the-fly, 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;		}	}}public void validate () {	// we can't validate a not-yet-addNotifyed Component	if ( (flags & IS_ADD_NOTIFIED) != 0 ) {		flags |= IS_VALID;	}}  /**   * Dummy lightweight peer singleton.   */  private static final DoNothingPeer DUMMY_PEER = new DoNothingPeer ();}

⌨️ 快捷键说明

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