java.awt.Window.getBackground()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中java.awt.Window.getBackground()方法的一些代码示例,展示了Window.getBackground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getBackground()方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getBackground

Window.getBackground介绍

暂无

代码示例

代码示例来源:origin: net.java.dev.jna/platform

/** Note that the property
 * <code>apple.awt.draggableWindowBackground</code> must be set to its
 * final value <em>before</em> the heavyweight peer for the Window is
 * created.  Once {@link Component#addNotify} has been called on the
 * component, causing creation of the heavyweight peer, changing this
 * property has no effect.
 * @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
 */
public void setWindowTransparent(Window w, boolean transparent) {
  boolean isTransparent = w.getBackground() != null
    && w.getBackground().getAlpha() == 0;
  if (transparent != isTransparent) {
    setBackgroundTransparent(w, transparent, "setWindowTransparent");
  }
}

代码示例来源:origin: net.java.dev.jna/jna-platform

/** Note that the property
 * <code>apple.awt.draggableWindowBackground</code> must be set to its
 * final value <em>before</em> the heavyweight peer for the Window is
 * created.  Once {@link Component#addNotify} has been called on the
 * component, causing creation of the heavyweight peer, changing this
 * property has no effect.
 * @see <a href="http://developer.apple.com/technotes/tn2007/tn2196.html#APPLE_AWT_DRAGGABLEWINDOWBACKGROUND">Apple Technote 2007</a>
 */
@Override
public void setWindowTransparent(Window w, boolean transparent) {
  boolean isTransparent = w.getBackground() != null
    && w.getBackground().getAlpha() == 0;
  if (transparent != isTransparent) {
    setBackgroundTransparent(w, transparent, "setWindowTransparent");
  }
}

代码示例来源:origin: com.jtattoo/JTattoo

public static void setTranslucentWindow(Window wnd, boolean translucent) {
  if (isTranslucentWindowSupported()) {
    if (JTattooUtilities.getJavaVersion() >= 1.7) {
      if (translucent) {
        if (wnd.getBackground() == null || !wnd.getBackground().equals(new Color(0, 0, 0, 0))) {
          wnd.setBackground(new Color(0, 0, 0, 0));
        }
      } else {
        if (wnd.getBackground() == null || !wnd.getBackground().equals(new Color(0, 0, 0, 0xff))) {
          wnd.setBackground(new Color(0, 0, 0, 0xff));
        }
      }
    } else if (JTattooUtilities.getJavaVersion() >= 1.6010) {
      try {
        Class clazz = Class.forName("com.sun.awt.AWTUtilities");
        Class classParams[] = {Window.class, Boolean.TYPE};
        Method method = clazz.getMethod("setWindowOpaque", classParams);
        if (translucent) {
          Object methodParams[] = {wnd, Boolean.FALSE};
          method.invoke(wnd, methodParams);
        } else {
          Object methodParams[] = {wnd, Boolean.TRUE};
          method.invoke(wnd, methodParams);
        }
      } catch (Exception ex) {
      }
    }
  }
}

代码示例来源:origin: net.java.dev.jna/platform

throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows");
boolean isTransparent = w.getBackground() != null
  && w.getBackground().getAlpha() == 0;
if (transparent == isTransparent)
  return;

代码示例来源:origin: net.java.dev.jna/jna-platform

throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows");
boolean isTransparent = w.getBackground() != null
  && w.getBackground().getAlpha() == 0;
if (transparent == isTransparent)
  return;

代码示例来源:origin: net.java.dev.jna/platform

throw new IllegalArgumentException("Window GraphicsConfiguration '" + w.getGraphicsConfiguration() + "' does not support transparency");
boolean isTransparent = w.getBackground() != null
  && w.getBackground().getAlpha() == 0;
if (transparent == isTransparent)
  return;

代码示例来源:origin: net.java.dev.jna/jna-platform

throw new IllegalArgumentException("Window GraphicsConfiguration '" + w.getGraphicsConfiguration() + "' does not support transparency");
boolean isTransparent = w.getBackground() != null
  && w.getBackground().getAlpha() == 0;
if (transparent == isTransparent)
  return;

代码示例来源:origin: net.java.dev.jna/jna-platform

private void setBackgroundTransparent(Window w, boolean transparent, String context) {
    JRootPane rp = w instanceof RootPaneContainer
      ? ((RootPaneContainer)w).getRootPane() : null;
    if (transparent) {
      if (rp != null) {
        rp.putClientProperty(TRANSPARENT_OLD_BG, w.getBackground());
      }
      w.setBackground(new Color(0,0,0,0));
    }
    else {
      if (rp != null) {
        Color bg = (Color)rp.getClientProperty(TRANSPARENT_OLD_BG);
        // If the old bg is a
        // apple.laf.CColorPaintUIResource, the window's
        // transparent state will not change
        if (bg != null) {
          bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), bg.getAlpha());
        }
        w.setBackground(bg);
        rp.putClientProperty(TRANSPARENT_OLD_BG, null);
      }
      else {
        w.setBackground(null);
      }
    }
    fixWindowDragging(w, context);
  }
}

代码示例来源:origin: net.java.dev.jna/platform

private void setBackgroundTransparent(Window w, boolean transparent, String context) {
    JRootPane rp = w instanceof RootPaneContainer
      ? ((RootPaneContainer)w).getRootPane() : null;
    if (transparent) {
      if (rp != null) {
        rp.putClientProperty(TRANSPARENT_OLD_BG, w.getBackground());
      }
      w.setBackground(new Color(0,0,0,0));
    }
    else {
      if (rp != null) {
        Color bg = (Color)rp.getClientProperty(TRANSPARENT_OLD_BG);
        // If the old bg is a
        // apple.laf.CColorPaintUIResource, the window's
        // transparent state will not change
        if (bg != null) {
          bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), bg.getAlpha());
        }
        w.setBackground(bg);
        rp.putClientProperty(TRANSPARENT_OLD_BG, null);
      }
      else {
        w.setBackground(null);
      }
    }
    fixWindowDragging(w, context);
  }
}

代码示例来源:origin: stackoverflow.com

Color defaultBackground = getBackground();
float defaultOpacity = getOpacity();

代码示例来源:origin: stackoverflow.com

public void printFrameColor(){
  System.out.println(MainController.getInstance().frame.getBackground());

代码示例来源:origin: stackoverflow.com

this.window = window;
this.dialog = dialog;
this.colorBG = window.getBackground();
this.opacity = window.getOpacity();
colorBG = dialog.getBackground();
opacity = dialog.getOpacity();
dialog.setOpacity(1.0f);  // Must call 1st

相关文章

Window类方法