/** Return the default graphics configuration. */ @Override public GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { if (isWindowAlphaSupported()) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length; j++) { long visualID = getVisualID(configs[j]); long[] ids = getAlphaVisualIDs(); for (int k = 0; k < ids.length; k++) { if (visualID == ids[k]) { return configs[j]; } } } } } return super.getAlphaCompatibleGraphicsConfiguration(); }
getWindow(w).addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { e.getWindow().removeWindowListener(this);
protected void setDoubleBuffered(Component root, boolean buffered) { if (root instanceof JComponent) { ((JComponent)root).setDoubleBuffered(buffered); } if (root instanceof JRootPane && buffered) { ((JRootPane)root).setDoubleBuffered(true); } else if (root instanceof Container) { Component[] kids = ((Container)root).getComponents(); for (int i=0;i < kids.length;i++) { setDoubleBuffered(kids[i], buffered); } } }
getWindow(w).addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) {
/** Return the default graphics configuration. */ public GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { if (isWindowAlphaSupported()) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length; j++) { long visualID = getVisualID(configs[j]); long[] ids = getAlphaVisualIDs(); for (int k = 0; k < ids.length; k++) { if (visualID == ids[k]) { return configs[j]; } } } } } return super.getAlphaCompatibleGraphicsConfiguration(); }
/** * Set the window to be transparent. Only explicitly painted pixels * will be non-transparent. All pixels will be composited with * whatever is under the window using their alpha values. * * On OSX, 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 static void setWindowTransparent(Window w, boolean transparent) { getInstance().setWindowTransparent(w, transparent); } }
/** * Set the overall window transparency. An alpha of 1.0 is fully * opaque, 0.0 fully transparent. The alpha level is applied equally * to all window pixels.<p> * NOTE: Windows requires that <code>sun.java2d.noddraw=true</code> * in order for alpha to work.<p> * NOTE: On OSX, 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 static void setWindowAlpha(Window w, float alpha) { getInstance().setWindowAlpha(w, Math.max(0f, Math.min(alpha, 1f))); }
/** * Requests a list of all currently available Desktop windows. * * @param onlyVisibleWindows * Specifies whether only currently visible windows will be * considered ({@code true}). That are windows which are not * minimized. The {@code WS_VISIBLE} flag will be checked (see: * <a href= * "https://msdn.microsoft.com/de-de/library/windows/desktop/ms633530%28v=vs.85%29.aspx" * >User32.IsWindowVisible(HWND)</a>). * * @return A list with all windows and some detailed information. */ public static List<DesktopWindow> getAllWindows( final boolean onlyVisibleWindows) { return getInstance().getAllWindows(onlyVisibleWindows); }
/** * Set the overall window transparency. An alpha of 1.0 is fully * opaque, 0.0 fully transparent. The alpha level is applied equally * to all window pixels.<p> * NOTE: Windows requires that <code>sun.java2d.noddraw=true</code> * in order for alpha to work.<p> * NOTE: On OSX, 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 static void setWindowAlpha(Window w, float alpha) { getInstance().setWindowAlpha(w, Math.max(0f, Math.min(alpha, 1f))); }
/** * Set the window to be transparent. Only explicitly painted pixels * will be non-transparent. All pixels will be composited with * whatever is under the window using their alpha values. * * On OSX, 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 static void setWindowTransparent(Window w, boolean transparent) { getInstance().setWindowTransparent(w, transparent); }
/** Set the window mask based on a {@link Shape}. */ public void setWindowMask(Component w, Shape mask) { setWindowMask(w, toRaster(mask)); }
protected void setDoubleBuffered(Component root, boolean buffered) { if (root instanceof JComponent) { ((JComponent)root).setDoubleBuffered(buffered); } if (root instanceof JRootPane && buffered) { ((JRootPane)root).setDoubleBuffered(true); } else if (root instanceof Container) { Component[] kids = ((Container)root).getComponents(); for (int i=0;i < kids.length;i++) { setDoubleBuffered(kids[i], buffered); } } }
/** * Applies the given mask to the given window. Does nothing if the * operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setWindowMask(Window w, Icon mask) { getInstance().setWindowMask(w, mask); }
public void setWindowMask(final Component w, final Shape mask) { if (mask instanceof Area && ((Area)mask).isPolygonal()) { setMask(w, (Area)mask); } else { super.setWindowMask(w, mask); } }
/** * Set the window mask based on the given Raster, which should * be treated as a bitmap (zero/nonzero values only). A value of * <code>null</code> means to remove the mask. */ protected void setWindowMask(Component w, Raster raster) { if (w.isLightweight()) throw new IllegalArgumentException("Component must be heavyweight: " + w); setMask(w, raster); }
/** * Set the window mask based on an Icon. All non-transparent * pixels will be included in the mask. */ public void setWindowMask(Component w, Icon mask) { setWindowMask(w, toRaster(w, mask)); }
/** * Applies the given mask to the given window. Does nothing if the * operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setWindowMask(Window w, Icon mask) { getInstance().setWindowMask(w, mask); }
/** * Applies the given mask to the given window. Does nothing if the * operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setWindowMask(Window w, Shape mask) { getInstance().setWindowMask(w, mask); }
@Override public void setWindowMask(final Component w, final Shape mask) { if (mask instanceof Area && ((Area)mask).isPolygonal()) { setMask(w, (Area)mask); } else { super.setWindowMask(w, mask); } }
/** * Set the window mask based on the given Raster, which should * be treated as a bitmap (zero/nonzero values only). A value of * <code>null</code> means to remove the mask. */ protected void setWindowMask(Component w, Raster raster) { if (w.isLightweight()) throw new IllegalArgumentException("Component must be heavyweight: " + w); setMask(w, raster); }