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

📄 component.java

📁 kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的java包。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				parent.repaint( x, y, width, height);			}			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_HIDDEN));		}				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));}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);}/** * @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-Graphics cache)	if ( g.link == null ){		li = new GraphicsLink( g);		g.link = li;	}	else {		li = g.link;	}		// set the target/link state (we don't want to use common Graphics objects	// with all that fuzz which is just needed for linked Graphicses)	li.xOffset   = g.xOffset;	li.yOffset   = g.yOffset;	li.next      = linkedGraphs;	li.width     = width;	li.height    = height;	li.isVisible = ((flags & IS_SHOWING) == IS_SHOWING);	g.target = this;		linkedGraphs = li;}/** * @deprecated, use getComponentAt(int, int) */public Component locate(int x, int y) {	// don't do a direct comparison here since transparent Components resolve contains()	return (contains( x, y) ? this : null);}/** * @deprecated, use getLocation() */public Point location() {	return new Point( x, y);}/** * @deprecated */public boolean lostFocus(Event evt, Object what) {	return (false);}/** * @deprecated, use getMinimumSize() */public Dimension minimumSize() {	return new Dimension( width, height);}/** * @deprecated */public boolean mouseDown(Event evt, int x, int y) {	return (false);}/** * @deprecated */public boolean mouseDrag(Event evt, int x, int y) {	return (false);}/** * @deprecated */public boolean mouseEnter(Event evt, int x, int y) {	return (false);}/** * @deprecated */public boolean mouseExit(Event evt, int x, int y) {	return (false);}/** * @deprecated */public boolean mouseMove(Event evt, int x, int y) {	return (false);}/** * @deprecated */public boolean mouseUp(Event evt, int x, int y) {	return (false);}/** * @deprecated, use setLocation(int, int) */public void move(int x, int y) {	setBounds(x, y, width, height);}/** * @deprecated, use transferFocus() */public void nextFocus() {	transferFocus();}public void paint ( Graphics g ) {	// nothing to do here, that all has to be donw in subclasses}public void paintAll ( Graphics g ) {	paint( g);}void kaffePaintBorder () {	Graphics g = getGraphics();	if ( g != null ) {		kaffePaintBorder( g);		g.dispose();	}}void kaffePaintBorder ( Graphics g ) {	kaffePaintBorder( g, 0, 0, 0, 0);}void kaffePaintBorder ( Graphics g, int left, int top, int right, int bottom ) {	int w = width - (left + right);	int h = height - (top + bottom);	if ( this == AWTEvent.keyTgt )		g.setColor( Defaults.FocusClr);	else		g.setColor( Defaults.BorderClr);	if (w-1 > 0 && h-1 > 0) {		g.draw3DRect( left, top,  w-1, h-1, true);	}	if (w-3 > 0 && h-3 > 0) {		g.draw3DRect( left+1, top+1, w-3, h-3, false);	}}protected String paramString () {	String s = name + ',' + x + ',' + y + ',' + width + 'x' + height;		if ( !isValid() )   s += ",invalid";		if ( !isVisible() ) s += ",hidden";	if ( !isEnabled() ) s += ",disabled";		return s;}/** * @deprecated */public boolean postEvent ( Event evt ) {	if ( evt != null ) {		// travel all the way up in the parent chain until we find someone who handles it		for ( Component c = this; c != null; c = c.parent ) {			if ( c.handleEvent( evt) ) {				evt.recycle();				return (true);			}// Commented out since it doubles an event's x// and y coordinates with the Main example for java.awt.Component// from the Java Class Libraries book.//			    evt.x += c.x;//			    evt.y += c.y;		}				evt.recycle();	}	return (false);}/** * @deprecated - use getPreferredSize() */public Dimension preferredSize () {	// DEP - this should go into getPreferredSize (just here because of JDK compat)	// Huhh, a deprecated method calling a non-deprecated one?? But that's the	// way JDK obviously does it (just directly calling getMinimumSize)	return getMinimumSize();}public boolean prepareImage ( Image image, ImageObserver obs ){	return (prepareImage (image, -1, -1, obs));}public boolean prepareImage ( Image image, int width, int height, ImageObserver obs ) {	return (Image.loadImage( image, width, height, obs));}public void print ( Graphics g ) {}public void printAll ( Graphics g ) {}void process ( ActionEvent e ) {	// we don't know nothing about ActionEventListeners}void process ( AdjustmentEvent e ) {	// we don't know nothing about AdjustmentEventListeners}void process ( ComponentEvent e ) {	if ( (cmpListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)		processEvent( e);}void process ( ContainerEvent e ) {	// we don't know nothing about ContainerEventListeners}void process ( FocusEvent e ) {	if ( AWTEvent.focusHook != null ){		if ( AWTEvent.focusHook.intercept( e) )			return;	}	if ( (focusListener != null) || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0){		processEvent( e);	}		if ( (flags & IS_OLD_EVENT) != 0 ) postEvent( Event.getEvent( e));}void process ( ItemEvent e ) {	// we don't know nothing about ItemEventListeners}void process ( KeyEvent e ) {	if ( AWTEvent.keyHook != null ){		if ( AWTEvent.keyHook.intercept( e) )			return;	}	if ( (keyListener != null) || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0){		processEvent( e);	}	if ( (flags & IS_OLD_EVENT) != 0 ) postEvent( Event.getEvent( e));}void process ( TextEvent e ) {	// we don't know nothing about TextEventListeners}void process ( WindowEvent e ) {	// we don't know nothing about WindowEventListeners}protected void processActionEvent ( ActionEvent e ) {}protected void processAdjustmentEvent ( AdjustmentEvent e ) {}protected void processComponentEvent ( ComponentEvent event ) {	if ( cmpListener != null ){		switch ( event.getID() ) {		case ComponentEvent.COMPONENT_RESIZED:			cmpListener.componentResized( event);			break;		case ComponentEvent.COMPONENT_MOVED:			cmpListener.componentMoved( event);			break;		case ComponentEvent.COMPONENT_SHOWN:			cmpListener.componentShown( event);			break;		case ComponentEvent.COMPONENT_HIDDEN:			cmpListener.componentHidden( event);			break;		}	}}protected void processContainerEvent ( ContainerEvent e ) {}protected void processEvent ( AWTEvent e ) {	// Wasn't there something called "object oriented programming"?	// Would be nice if we could do a simple "e.dispatch()" (to rely on	// method overloading to do the branching), but we can't because this	// is a protected method, which constantly gets overloaded for modification	// of standard event processing (which is mostly silly because it can be done	// with listeners)	switch ( e.id ){	case MouseEvent.MOUSE_CLICKED:	//500..506	case MouseEvent.MOUSE_PRESSED:	case MouseEvent.MOUSE_RELEASED:	case MouseEvent.MOUSE_ENTERED:	case MouseEvent.MOUSE_EXITED:		// Not hard to anticipate that there will be AWT test suites throwing synthetic		// events against real components. However, this is "out of spec", most native window		// environments would act on the emitter side (rather than the responder), like we do		// (in MouseEvt). Moreover, processEvent() might be resolved by a derived class		// if ( (eventMask & AWTEvent.DISABLED_MASK) == 0 )		processMouseEvent( (MouseEvent)e);		break;			case MouseEvent.MOUSE_MOVED:	case MouseEvent.MOUSE_DRAGGED:		processMouseMotionEvent( (MouseEvent)e);		break;			case KeyEvent.KEY_TYPED:			//400..402	case KeyEvent.KEY_PRESSED:	case KeyEvent.KEY_RELEASED:		// if ( (eventMask & AWTEvent.DISABLED_MASK) == 0 )		processKeyEvent( (KeyEvent)e);		break;				case FocusEvent.FOCUS_GAINED:	//1004..1005	case FocusEvent.FOCUS_LOST:		processFocusEvent( (FocusEvent)e);		break;	case PaintEvent.PAINT:	case PaintEvent.UPDATE:		Rectangle r = ((PaintEvent)e).getUpdateRect();		processPaintEvent( e.id, r.x, r.y, r.width, r.height);		break;			case ComponentEvent.COMPONENT_MOVED:	//100..103	case ComponentEvent.COMPONENT_RESIZED:	case ComponentEvent.COMPONENT_SHOWN:	case ComponentEvent.COMPONENT_HIDDEN:		processComponentEvent( (ComponentEvent)e);		break;			case ContainerEvent.COMPONENT_ADDED:	//300..301	case ContainerEvent.COMPONENT_REMOVED:		processContainerEvent( (ContainerEvent)e);		break;			case WindowEvent.WINDOW_OPENED:			//200..206	case WindowEvent.WINDOW_CLOSING:	case WindowEvent.WINDOW_CLOSED:	case WindowEvent.WINDOW_ICONIFIED:	case WindowEvent.WINDOW_DEICONIFIED:	case WindowEvent.WINDOW_ACTIVATED:	case WindowEvent.WINDOW_DEACTIVATED:		processWindowEvent( (WindowEvent)e);		break;				case TextEvent.TEXT_VALUE_CHANGED:	//900		processTextEvent( (TextEvent)e);		break;				case ItemEvent.ITEM_STATE_CHANGED:	//701		processItemEvent( (ItemEvent)e);		break;				case ActionEvent.ACTION_PERFORMED:	//1001		processActionEvent( (ActionEvent)e);		break;				case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:	//601		processAdjustmentEvent( (AdjustmentEvent)e);		break;	}}protected void processFocusEvent ( FocusEvent event ) {	if ( focusListener != null ) {		switch ( event.getID() ) {		case FocusEvent.FOCUS_GAINED:			focusListener.focusGained( event);			break;		case FocusEvent.FOCUS_LOST:			focusListener.focusLost( event);			break;		}	}}protected void processItemEvent ( ItemEvent e ) {}protected void processKeyEvent ( KeyEvent event ) {	if ( keyListener != null ) {		switch ( event.id ) {		case KeyEvent.KEY_TYPED:			keyListener.keyTyped( event);			break;		case KeyEvent.KEY_PRESSED:			keyListener.keyPressed( event);			break;		case KeyEvent.KEY_RELEASED:			keyListener.keyReleased( event);			break;		}	}}void processMotion ( MouseEvent e ) {	if ( AWTEvent.mouseHook != null ){		if ( AWTEvent.mouseHook.intercept( e) )			return;	}	if ( (motionListener != null) || (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0)		processEvent( e);	if ( (flags & IS_OLD_EVENT) != 0 ){		postEvent( Event.getEvent( e));	}}void processMouse ( MouseEvent e ) {	if ( AWTEvent.mouseHook != null ){		if ( AWTEvent.mouseHook.intercept( e) )			return;	}	if ( (mouseListener != null) || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0)		processEvent( e);	if ( (flags & IS_OLD_EVENT) != 0 ){		postEvent( Event.getEvent( e));	}}protected void processMouseEvent ( MouseEvent event ) {	if ( mouseListener != null ) {		switch ( event.id ) {			case MouseEvent.MOUSE_PRESSED:				mouseListener.mousePressed( event);				break;

⌨️ 快捷键说明

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