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

📄 container.java

📁 java virtual machince kaffe
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   * @param p - the component's location   * @return null if the component does not contain the position.    * If there is no child component at the requested point and the point is    * within the bounds of the container the container itself is returned.   * @since 1.2   */  public Component findComponentAt(Point p)  {    return findComponentAt(p.x, p.y);  }public Component getComponentAt ( int x, int y ) {	return locate ( x, y);}public int getComponentCount() {	return countComponents();}public Component[] getComponents () {	Component ca[] = new Component[ncomponents];		if ( ncomponents > 0 )		System.arraycopy( component, 0, ca, 0, ncomponents);		return ca;}public Insets getInsets () {	return insets();}public LayoutManager getLayout () {	return (layoutMgr);}public Dimension getMaximumSize () {	if (layoutMgr instanceof LayoutManager2) {		return (((LayoutManager2)layoutMgr).maximumLayoutSize(this));	}	else {		return (super.getMaximumSize());	}}public Dimension getMinimumSize () {	return (minimumSize());}public Dimension getPreferredSize () {	return (preferredSize());}boolean hasDirties () {	for ( int i=0; i<ncomponents; i++ ) {		Component c = component[i];				if ( (c.flags & IS_DIRTY) != 0 )			return true;		if ( c instanceof Container ) {			if ( ((Container)c).hasDirties() )				return true;		}	}		return false;}public void hide () {	if ( (flags & IS_PARENT_SHOWING) != 0){		for ( int i=0; i<ncomponents; i++ ) {			Component c = component[i];						c.flags &= ~IS_PARENT_SHOWING;			if ( (c.flags & IS_VISIBLE) != 0 )				c.propagateParentShowing( false);		}	}	super.hide();}/** * @deprecated, use getInsets() */public Insets insets () {	// DEP - this should be in getInsets()	// a Swing LabelPane outcoming (since peers seem to return	// the *real* inset object, it wouldn't be necessary to copy, otherwise)	return new Insets( insets.top, insets.left, insets.bottom, insets.right);}public void invalidate () {	synchronized ( treeLock ) {		if ( (flags & IS_VALID) != 0 ) {			// apparently, the JDK does inform the layout *before* invalidation			if ( layoutMgr instanceof LayoutManager2 ) {				((LayoutManager2)layoutMgr).invalidateLayout( this);			}					flags &= ~IS_VALID;					// we have to check the parent since we might be a Window			if ( (parent != null) && ((parent.flags & IS_VALID) != 0) )				parent.invalidate();		}	}}public boolean isAncestorOf ( Component c ) {	for ( c = c.parent; c != null; c = c.parent) {		if ( c == this ) return true;	}	return false;}public void layout() {	// DEP - this should be in doLayout() (another nasty compat issue)	// We keep the 'isLayouting' state regardless of the validation scheme, since	// it is the way to prevent lots of redraws during recursive layout descents	// another slow-downer: the async validation of swing forces us to sync on treeLock	synchronized ( treeLock ) {    // swing books need layout even without children		if ( (layoutMgr != null) && ((flags & IS_LAYOUTING) == 0) ) {			flags |= IS_LAYOUTING;			layoutMgr.layoutContainer( this);			flags &= ~IS_LAYOUTING;		}	}}public void list(PrintStream out, int indent) {    list(new PrintWriter(out), indent);}public void list(PrintWriter out, int indent) {    super.list(out, indent);    Component[] comps = getComponents();    for (int i = comps.length - 1; i >= 0; --i) {	comps[i].list(out, indent + 2);    }    out.flush();}/** * @deprecated, use getComponentAt(). */public Component locate ( int x, int y ) {	Component c;	if ( !isShowing() || (x<0) || (x > this.x+width) || (y<0) || (y > this.y+height) )		return null;			for ( int i=0; i<ncomponents; i++ ) {		c = component[i];		if ( c.contains( x - c.x, y - c.y)) {			return (c.isShowing() ? c : this);		}	}		return this;}void markRepaints ( int ux, int uy, int uw, int uh ) {	int uxw = ux + uw;	int uyh = uy + uh;	for ( int i=0; i<ncomponents; i++ ) {		Component c = component[i];		if ( (c.flags & IS_VISIBLE) != 0 ){			int cxw = c.x + c.width;			int cyh = c.y + c.height;						if ( (ux < cxw) && (uy < cyh) && (c.x < uxw) && (c.y < uyh) ){				if ( (c.flags & IS_NATIVE_LIKE) != 0) {					c.flags |= IS_DIRTY;				}						if ( c instanceof Container ) {					int uxx = (ux < c.x ) ? 0 : ux - c.x;					int uyy = (uy < c.y ) ? 0 : uy - c.y;					int uww = (uxw < cxw) ? (uxw - c.x - uxx) : c.width;					int uhh = (uyh < cyh) ? (uyh - c.y - uyy) : c.height;									((Container)c).markRepaints( uxx, uyy, uww, uhh);				}			}		}	}}/** * @deprecated, use getMinimumSize() */public Dimension minimumSize () {	if ( layoutMgr != null ) {		return layoutMgr.minimumLayoutSize( this);	}	else {		return super.minimumSize();	}}public void paint ( Graphics g ) {	// standard JDK behavior is to paint last added childs first, simulating	// a first-to-last z order	validateTree();	for ( int i=ncomponents-1; i>=0; i-- ) {		Component c = component[i];		if ( (c.flags & IS_VISIBLE) != 0 ) {			g.paintChild( c, (flags & IS_IN_UPDATE) != 0);		}	}}public void paintComponents(Graphics gc) {	Component[] comps = getComponents();	for (int i = comps.length; i > 0; --i) {		comps[i].paintAll(gc);	}}protected String paramString() {    return super.paramString() + ",layout=" + getLayout().getClass().getName();}/** * @deprecated, use getPreferredSize(). */public Dimension preferredSize () {	if ( layoutMgr != null ) {		return (layoutMgr.preferredLayoutSize(this));	}	else {		return (super.preferredSize());	}}public void printComponents ( Graphics g ) {}void process ( ContainerEvent e ) {	if ( (containerListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)		processEvent( e);}public void processContainerEvent ( ContainerEvent event ) {	if ( containerListener != null ) {		switch ( event.getID() ) {		case ContainerEvent.COMPONENT_ADDED:			containerListener.componentAdded( event);			break;		case ContainerEvent.COMPONENT_REMOVED:			containerListener.componentRemoved( event);			break;		}	}}void processPaintEvent ( int id, int ux, int uy, int uw, int uh ) {	NativeGraphics g = NativeGraphics.getClippedGraphics( null, this, 0,0,	                                                      ux, uy, uw, uh,	                                                      false);	if ( g != null ){		markRepaints( ux, uy, uw, uh);			if ( id == PaintEvent.UPDATE ) {			update( g);		}		else {			paint( g);		}		g.dispose();			if ( hasDirties() )			emitRepaints( ux, uy, uw, uh);	}}void propagateBgClr ( Color clr ) {	background = clr;	for ( int i=0; i<ncomponents; i++ ){		Component c = component[i];		if ( (c.flags & IS_BG_COLORED) == 0 ){			c.propagateBgClr( clr);		}	}}void propagateFgClr ( Color clr ) {	foreground = clr;	for ( int i=0; i<ncomponents; i++ ){		Component c = component[i];		if ( (c.flags & IS_FG_COLORED) == 0 ){			c.propagateFgClr( clr);		}	}}void propagateFont ( Font fnt ) {	font = fnt;	for ( int i=0; i<ncomponents; i++ ){		Component c = component[i];		if ( (c.flags & IS_FONTIFIED) == 0 ){			c.propagateFont( fnt);		}	}}void propagateParentShowing ( boolean isTemporary ) {	if ( (flags & IS_VISIBLE) == 0 ) // nothing to do, we are a visibility leaf		return;	if ( (flags & IS_PARENT_SHOWING) != 0 ) {		for ( int i=0; i<ncomponents; i++ ){			component[i].flags |= IS_PARENT_SHOWING;			component[i].propagateParentShowing( isTemporary);		}	}	else {		for ( int i=0; i<ncomponents; i++ ){			component[i].flags &= ~IS_PARENT_SHOWING;			component[i].propagateParentShowing( isTemporary);		}	}		if ( !isTemporary ) {		// notify resident Graphics objects		if ( linkedGraphs != null )			updateLinkedGraphics();	}}void propagateReshape () {	for ( int i=0; i<ncomponents; i++ ){		component[i].propagateReshape();	}		// notify resident Graphics objects	if ( linkedGraphs != null )		updateLinkedGraphics();}void propagateTempEnabled ( boolean isEnabled ) {	super.propagateTempEnabled ( isEnabled );	for ( int i=0; i<ncomponents; i++ ){		component[i].propagateTempEnabled( isEnabled);	}}public void remove ( Component c ) {	// usually children are added/removed in a stack like fashion	for ( int i=ncomponents-1; i>=0; i-- ){		if ( component[i] == c ) {			remove(i);			break;		}	}}public void remove ( int index ) {	synchronized ( treeLock ) {		int n = ncomponents - 1;		if (index < 0 && index > n) {			return;		}				Component c = component[index];		if ( (c.flags & IS_ADD_NOTIFIED) != 0 ){			c.removeNotify();		}		if ( layoutMgr != null ) {			layoutMgr.removeLayoutComponent( c);		}		// Remove from container		c.parent = null;		if (index > -1 && index < n) {			System.arraycopy(component, index+1, component, index, n-index);		}		component[n] = null;		ncomponents--;		if ( (containerListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ){			AWTEvent.sendEvent( ContainerEvt.getEvent( this,			                       ContainerEvent.COMPONENT_REMOVED, c), false);		}		if ( (flags & IS_VALID) != 0 )			invalidate();		c.flags &= ~IS_PARENT_SHOWING;		c.propagateParentShowing( false);		// Like in addImpl, this wouldn't be required in case we are subsequently		// validated, again. However, native widgets cause a repaint regardless		// of this validation		if ( (c.flags & IS_NATIVE_LIKE) != 0 )			repaint( c.x, c.y, c.width, c.height);	}}public void removeAll () {	// let's try to do some upfront paint solicitation in case we have	// a lot of children (note that we have to call remove(idx) since it	// might be reimplemented in a derived class)	if ( ncomponents > 3 ) {		int oldFlags = flags;		flags &= ~IS_VISIBLE;		for ( int i = ncomponents-1; i >= 0; i-- )			remove(i);		flags = oldFlags;		repaint();	}	else {			for ( int i = ncomponents-1; i >= 0; i-- )			remove(i);	}}public void removeContainerListener ( ContainerListener listener ) {	containerListener = AWTEventMulticaster.remove( containerListener, listener);}public void removeNotify() {	// removeNotify children first (symmetric to addNotify)	for ( int i=0; i<ncomponents; i++ ) {		if ( (component[i].flags & IS_ADD_NOTIFIED) != 0 ) {			component[i].removeNotify();		}	}	super.removeNotify();}

⌨️ 快捷键说明

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