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

📄 window.java

📁 linux下编程用 编译软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  {    this.windowFocusOwner = windowFocusOwner;  }  /**   * Post a Java 1.0 event to the event queue.   *   * @param e The event to post.   *   * @deprecated   */  public boolean postEvent(Event e)  {    return handleEvent (e);  }  /**   * Tests whether or not this window is visible on the screen.   *   * In contrast to the normal behaviour of Container, which is that   * a container is showing if its parent is visible and showing, a Window   * is even showing, if its parent (i.e. an invisible Frame) is not showing.   *   * @return <code>true</code> if this window is visible, <code>false</code>   * otherwise.   */  public boolean isShowing()  {    return isVisible();  }  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);  }  /**   * A BltBufferStrategy for windows.   */  private class WindowBltBufferStrategy extends BltBufferStrategy  {    /**     * Creates a block transfer strategy for this window.     *     * @param numBuffers the number of buffers in this strategy     * @param accelerated true if the buffer should be accelerated,     * false otherwise     */    WindowBltBufferStrategy(int numBuffers, boolean accelerated)    {      super(numBuffers,	    new BufferCapabilities(new ImageCapabilities(accelerated),				   new ImageCapabilities(accelerated),				   BufferCapabilities.FlipContents.COPIED));    }  }  /**   * A FlipBufferStrategy for windows.   */  private class WindowFlipBufferStrategy extends FlipBufferStrategy  {    /**     * Creates a flip buffer strategy for this window.     *     * @param numBuffers the number of buffers in this strategy     *     * @throws AWTException if the requested number of buffers is not     * supported     */    WindowFlipBufferStrategy(int numBuffers)      throws AWTException    {      super(numBuffers,	    new BufferCapabilities(new ImageCapabilities(true),				   new ImageCapabilities(true),				   BufferCapabilities.FlipContents.COPIED));    }  }  /**   * Creates a buffering strategy that manages how this window is   * repainted.  This method attempts to create the optimum strategy   * based on the desired number of buffers.  Hardware or software   * acceleration may be used.   *   * createBufferStrategy attempts different levels of optimization,   * but guarantees that some strategy with the requested number of   * buffers will be created even if it is not optimal.  First it   * attempts to create a page flipping strategy, then an accelerated   * blitting strategy, then an unaccelerated blitting strategy.   *   * Calling this method causes any existing buffer strategy to be   * destroyed.   *   * @param numBuffers the number of buffers in this strategy   *   * @throws IllegalArgumentException if requested number of buffers   * is less than one   * @throws IllegalStateException if this window is not displayable   *   * @since 1.4   */  public void createBufferStrategy(int numBuffers)  {    if (numBuffers < 1)      throw new IllegalArgumentException("Window.createBufferStrategy: number"					 + " of buffers is less than one");    if (!isDisplayable())      throw new IllegalStateException("Window.createBufferStrategy: window is"				      + " not displayable");    BufferStrategy newStrategy = null;    // try a flipping strategy    try      {	newStrategy = new WindowFlipBufferStrategy(numBuffers);      }    catch (AWTException e)      {      }    // fall back to an accelerated blitting strategy    if (newStrategy == null)      newStrategy = new WindowBltBufferStrategy(numBuffers, true);    bufferStrategy = newStrategy;  }  /**   * Creates a buffering strategy that manages how this window is   * repainted.  This method attempts to create a strategy based on   * the specified capabilities and throws an exception if the   * requested strategy is not supported.   *   * Calling this method causes any existing buffer strategy to be   * destroyed.   *   * @param numBuffers the number of buffers in this strategy   * @param caps the requested buffering capabilities   *   * @throws AWTException if the requested capabilities are not   * supported   * @throws IllegalArgumentException if requested number of buffers   * is less than one or if caps is null   *   * @since 1.4   */  public void createBufferStrategy(int numBuffers, BufferCapabilities caps)    throws AWTException  {    if (numBuffers < 1)      throw new IllegalArgumentException("Window.createBufferStrategy: number"					 + " of buffers is less than one");    if (caps == null)      throw new IllegalArgumentException("Window.createBufferStrategy:"					 + " capabilities object is null");    // a flipping strategy was requested    if (caps.isPageFlipping())      bufferStrategy = new WindowFlipBufferStrategy(numBuffers);    else      bufferStrategy = new WindowBltBufferStrategy(numBuffers, true);  }  /**   * Returns the buffer strategy used by the window.   *   * @return the buffer strategy.   * @since 1.4   */  public BufferStrategy getBufferStrategy()  {    return bufferStrategy;  }  /**   * @since 1.2   *   * @deprecated   */  public void applyResourceBundle(ResourceBundle rb)  {    throw new Error ("Not implemented");  }  /**   * @since 1.2   *   * @deprecated   */  public void applyResourceBundle(String rbName)  {    ResourceBundle rb = ResourceBundle.getBundle(rbName, Locale.getDefault(),      ClassLoader.getSystemClassLoader());    if (rb != null)      applyResourceBundle(rb);      }  /**   * Gets the AccessibleContext associated with this <code>Window</code>.   * The context is created, if necessary.   *   * @return the associated context   */  public AccessibleContext getAccessibleContext()  {    /* Create the context if this is the first request */    if (accessibleContext == null)      accessibleContext = new AccessibleAWTWindow();    return accessibleContext;  }  /**    * Get graphics configuration.  The implementation for Window will   * not ask any parent containers, since Window is a toplevel   * window and not actually embedded in the parent component.   */  public GraphicsConfiguration getGraphicsConfiguration()  {    if (graphicsConfiguration != null) return graphicsConfiguration;    if (peer != null) return peer.getGraphicsConfiguration();    return null;  }  protected void processWindowFocusEvent(WindowEvent event)  {    if (windowFocusListener != null)      {        switch (event.getID ())          {          case WindowEvent.WINDOW_GAINED_FOCUS:            windowFocusListener.windowGainedFocus (event);            break;                      case WindowEvent.WINDOW_LOST_FOCUS:            windowFocusListener.windowLostFocus (event);            break;                      default:            break;          }      }  }    /**   * @since 1.4   */  protected void processWindowStateEvent(WindowEvent event)  {    if (windowStateListener != null        && event.getID () == WindowEvent.WINDOW_STATE_CHANGED)      windowStateListener.windowStateChanged (event);  }  /**   * 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;  }  /**   * Generate a unique name for this window.   *   * @return A unique name for this window.   */  String generateName()  {    return "win" + getUniqueLong();  }  private static synchronized long getUniqueLong()  {    return next_window_number++;  }}

⌨️ 快捷键说明

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