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); } }
@Override protected void setWindowMask(Component w, Raster raster) { if (raster != null) { setWindowMask(w, toShape(raster)); } else { setWindowMask(w, new Rectangle(0, 0, w.getWidth(), w.getHeight())); } }
/** 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 setWindowAlpha(final Window w, final float alpha) { if (w instanceof RootPaneContainer) { JRootPane p = ((RootPaneContainer)w).getRootPane(); p.putClientProperty("Window.alpha", new Float(alpha)); fixWindowDragging(w, "setWindowAlpha"); } whenDisplayable(w, new Runnable() { public void run() { Object peer = w.getPeer(); try { peer.getClass().getMethod("setAlpha", new Class[]{ float.class }).invoke(peer, new Object[]{ new Float(alpha) }); } catch (Exception e) { } } }); }
JRootPane p = ((RootPaneContainer)w).getRootPane(); p.putClientProperty("Window.alpha", Float.valueOf(alpha)); fixWindowDragging(w, "setWindowAlpha"); whenDisplayable(w, new Runnable() { @Override public void run() {
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); } }
/** 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"); } }
/** 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"); } }
public void setWindowMask(Component c, final Shape shape) { if (c instanceof Window) { Window w = (Window)c; OSXMaskingContentPane content = installMaskingPane(w); content.setMask(shape); setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask"); } else { // not yet implemented } }
@Override public void setWindowMask(Component c, final Shape shape) { if (c instanceof Window) { Window w = (Window)c; OSXMaskingContentPane content = installMaskingPane(w); content.setMask(shape); setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask"); } else { // not yet implemented } }
protected void setWindowMask(Component w, Raster raster) { if (raster != null) { setWindowMask(w, toShape(raster)); } else { setWindowMask(w, new Rectangle(0, 0, w.getWidth(), w.getHeight())); } }