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

📄 window.java

📁 java virtual machince kaffe
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	if ( wndListener != null ) {		switch ( event.id ) {		case WindowEvent.WINDOW_OPENED:			wndListener.windowOpened( event);			break;		case WindowEvent.WINDOW_CLOSED:			wndListener.windowClosed( event);			break;		}	}}public void removeNotify () {	if ( (flags & IS_ADD_NOTIFIED) != 0 ) {		// use this rather than nativeData, because the sync FOCUS_LOST might get us recursive    flags &= ~IS_ADD_NOTIFIED;		// if there are resident Graphics objects used in respond to a focusLost,		// we might get problems because of an already deleted window - we better		// simulate sync what has to be processed anyway (this error typically shows		// up in a KaffeServer context)		if ( (AWTEvent.activeWindow == this) && (AWTEvent.keyTgt != null) ){			AWTEvent.sendEvent( FocusEvt.getEvent( AWTEvent.keyTgt,			                                       FocusEvent.FOCUS_LOST, false), true);		}		super.removeNotify();		// this might cause a context switch, since we have to do it sync		// (to prevent double-destroys for things like the swing popup		// removeNotify jitter)		Toolkit.destroyNative( this);		if ( (wndListener != null) || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 ){			AWTEvent.sendEvent( WindowEvt.getEvent( this,						                        WindowEvent.WINDOW_CLOSED), false);		}	}}public void removeWindowListener ( WindowListener listener ) {	wndListener = AWTEventMulticaster.remove( wndListener, listener);}public void requestFocus () {	if ( (nativeData != null) && ((flags & IS_VISIBLE) != 0) ){		Toolkit.wndRequestFocus( nativeData);	}}public void reshape ( int xNew, int yNew, int wNew, int hNew ) {	// DEP - this should be in setBounds (the deprecated ripple effect!)	// this is never called by a native toplevel resize	if ( (xNew == x) && (yNew == y) && (wNew == width) && (hNew == height) )		return;  // avoid flicker of redundant reshapes	// Some people don't trust the automatic validation and call validate() explicitly	// right after a reshape. We wouldn't get this is we wait for the automatic	// invalidation during ComponentEvt.getEvent() (hello again, SwingSet..)	if ( (wNew != width) || (hNew != height) )		invalidate();	x      = xNew;	y      = yNew;	width  = wNew;	height = hNew;	if ( nativeData != null ) {		if ( (Toolkit.flags & Toolkit.EXTERNAL_DECO) != 0 ){			// we have to fake a bit with native coordinates, since we pretend to own the			// whole real estate of the toplevel (including the deco), but we don't in reality			xNew += deco.x;			yNew += deco.y;			wNew -= deco.width;			hNew -= deco.height;		}		Toolkit.wndSetBounds( nativeData, xNew, yNew, wNew, hNew, ((flags & IS_RESIZABLE) != 0));	}}public void setBackground ( Color clr ) {	// we can't nullify this (rermember the "background != null" invariant)	if ( clr != null ) {		background = clr;		propagateBgClr( clr);		if ( isShowing() )			repaint();	}}public void setFont ( Font fnt ) {	// we can't nullify this (remember the "font != null" invariant)	if ( fnt != null ) {		font = fnt;		propagateFont( fnt);		if ( isShowing() )			repaint();	}}public void setForeground ( Color clr ) {	// we can't nullify this (rermember the "foreground != null" invariant)	if ( clr != null ) {		foreground = clr;		propagateFgClr( clr);		if ( isShowing() )			repaint();	}}void setNativeCursor ( Cursor cursor ) {	if ( nativeData != null )		Toolkit.wndSetCursor( nativeData, cursor.type);}public void show() {	if ( nativeData == null ){		addNotify();	}	// this happens to be one of the automatic validation points, and it should	// cause a layout *before* we get visible	validate();	if ( (flags & IS_VISIBLE) != 0 ) {		toFront();	}	else {		super.show();		// Some apps carelessly start to draw (or do other display related things)		// immediately after a show(), which is usually not called from the		// event dispatcher thread. If we don't wait until the window is mapped, this		// output is lost. But if we do, we might get into trouble with things like		// swing (with its show->removeNotify->show jitter for popups). Since it isn't		// specified, and the JDK does not provide reliable sync, we skip it for now		// (local dispatching should be kept to a minimum)		Toolkit.wndSetVisible( nativeData, true);		// the spec says that WINDOW_OPENED is delivered the first time a Window		// is shown, and JDK sends this after it got shown, so this is the place		if ( (flags & IS_OPENED) == 0 ) {			flags |= IS_OPENED;			if ( (wndListener != null) || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 ){				AWTEvent.sendEvent( WindowEvt.getEvent( this,				                        WindowEvent.WINDOW_OPENED), false);			}		}	}}public void toBack () {	if ( nativeData != null ) Toolkit.wndToBack( nativeData);}public void toFront () {	if ( nativeData != null ) Toolkit.wndToFront( nativeData);}public void setLocationRelativeTo(Component c) {    int x = 0;    int y = 0;        if (c == null || !c.isShowing())      {        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();        Point center = ge.getCenterPoint();        x = center.x - (width / 2);        y = center.y - (height / 2);      }    else      {        int cWidth = c.getWidth();        int cHeight = c.getHeight();        Dimension screenSize = getToolkit().getScreenSize();        x = c.getLocationOnScreen().x;        y = c.getLocationOnScreen().y;                // If bottom of component is cut off, window placed        // on the left or the right side of component        if ((y + cHeight) > screenSize.height)          {            // If the right side of the component is closer to the center            if ((screenSize.width / 2 - x) <= 0)              {                if ((x - width) >= 0)                  x -= width;                else                  x = 0;              }            else              {                if ((x + cWidth + width) <= screenSize.width)                  x += cWidth;                else                  x = screenSize.width - width;              }            y = screenSize.height - height;          }        else if (cWidth > width || cHeight > height)          {            // If right side of component is cut off            if ((x + width) > screenSize.width)              x = screenSize.width - width;            // If left side of component is cut off            else if (x < 0)              x = 0;            else              x += (cWidth - width) / 2;                        y += (cHeight - height) / 2;          }        else          {            // If right side of component is cut off            if ((x + width) > screenSize.width)              x = screenSize.width - width;            // If left side of component is cut off            else if (x < 0 || (x - (width - cWidth) / 2) < 0)              x = 0;            else              x -= (width - cWidth) / 2;            if ((y - (height - cHeight) / 2) > 0)              y -= (height - cHeight) / 2;            else              y = 0;          }      }    setLocation(x, y);}/*** Returns whether this <code>Window</code> can get the focus or not. * * @since 1.4 */public final boolean isFocusableWindow (){    if (getFocusableWindowState () == false)        return false;    if (this instanceof Dialog        || this instanceof Frame)        return true;    // FIXME: Implement more possible cases for returning true.    return false;}/*** Returns the value of the focusableWindowState property. * * @since 1.4 */public boolean getFocusableWindowState (){    return focusableWindowState;}/*** Sets the value of the focusableWindowState property. * * @since 1.4 */public void setFocusableWindowState (boolean focusableWindowState){    this.focusableWindowState = focusableWindowState;}public boolean isLightweight(){        return false;}}

⌨️ 快捷键说明

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