public void setOpaque(boolean isOpaque) {
    synchronized (getStateLock()) {
      if (this.isOpaque == isOpaque) {
        return;
      }
    }

    Window target = (Window) getTarget();

    if (!isOpaque) {
      SunToolkit sunToolkit = (SunToolkit) target.getToolkit();
      if (!sunToolkit.isWindowTranslucencySupported()
          || !sunToolkit.isTranslucencyCapable(target.getGraphicsConfiguration())) {
        return;
      }
    }

    boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();

    if (this.isOpaque != isOpaque && !isVistaOS) {
      // non-Vista OS: only replace the surface data if the opacity
      // status changed (see WComponentPeer.isAccelCapable() for more)
      replaceSurfaceDataRecursively(target);
    }

    synchronized (getStateLock()) {
      this.isOpaque = isOpaque;
      setOpaqueImpl(isOpaque);
      if (isOpaque) {
        TranslucentWindowPainter currentPainter = painter;
        if (currentPainter != null) {
          currentPainter.flush();
          painter = null;
        }
      } else {
        painter = TranslucentWindowPainter.createInstance(this);
      }
    }

    if (isVistaOS) {
      // On Vista: setting the window non-opaque makes the window look
      // rectangular, though still catching the mouse clicks within
      // its shape only. To restore the correct visual appearance
      // of the window (i.e. w/ the correct shape) we have to reset
      // the shape.
      Shape shape = target.getShape();
      if (shape != null) {
        target.setShape(shape);
      }
    }

    if (target.isVisible()) {
      updateWindow(true);
    }
  }
  public void setOpacity(float opacity) {
    if (!((SunToolkit) ((Window) target).getToolkit()).isWindowOpacitySupported()) {
      return;
    }

    if (opacity < 0.0f || opacity > 1.0f) {
      throw new IllegalArgumentException(
          "The value of opacity should be in the range [0.0f .. 1.0f].");
    }

    if (((this.opacity == 1.0f && opacity < 1.0f) || (this.opacity < 1.0f && opacity == 1.0f))
        && !Win32GraphicsEnvironment.isVistaOS()) {
      // non-Vista OS: only replace the surface data if opacity status
      // changed (see WComponentPeer.isAccelCapable() for more)
      replaceSurfaceDataRecursively((Component) getTarget());
    }

    this.opacity = opacity;

    final int maxOpacity = 0xff;
    int iOpacity = (int) (opacity * maxOpacity);
    if (iOpacity < 0) {
      iOpacity = 0;
    }
    if (iOpacity > maxOpacity) {
      iOpacity = maxOpacity;
    }

    setOpacity(iOpacity);

    synchronized (getStateLock()) {
      if (!isOpaque && ((Window) target).isVisible()) {
        updateWindow(true);
      }
    }
  }