Top Description Inners Fields Constructors Methods
com.sun.jna.examples

public Class WindowUtils

extends Object
Class Inheritance
Imports
java.awt.AlphaComposite, .BorderLayout, .Color, .Component, .Container, .Graphics, .Graphics2D, .GraphicsConfiguration, .GraphicsDevice, .GraphicsEnvironment, .Point, .Rectangle, .Shape, .Window, java.awt.event.ComponentEvent, .ComponentListener, .HierarchyEvent, .HierarchyListener, .WindowAdapter, .WindowEvent, java.awt.geom.Area, java.awt.image.BufferedImage, .Raster, java.util.ArrayList, .List, javax.swing.Icon, .JComponent, .JLayeredPane, .JPanel, .JRootPane, .PopupFactory, .RootPaneContainer, .SwingUtilities, com.sun.jna.Native, .NativeLong, .Platform, .Pointer, com.sun.jna.examples.unix.X11, .X11.Display, .X11.Drawable, .X11.GC, .X11.Pixmap, .X11.XVisualInfo, .X11.Xext, .X11.Xrender.XRenderPictFormat, com.sun.jna.examples.win32.GDI32, .User32, .GDI32.BITMAPINFO, .User32.BLENDFUNCTION, .User32.POINT, .User32.SIZE, .W32API.HANDLE, .W32API.HBITMAP, .W32API.HDC, .W32API.HRGN, .W32API.HWND, com.sun.jna.ptr.ByteByReference, .IntByReference, .PointerByReference

Provides additional features on a Java Window. NOTE: since there is no explicit way to force PopupFactory to use a heavyweight popup, and anything but a heavyweight popup will be clipped by a window mask, an additional subwindow is added to all masked windows to implicitly force PopupFactory to use a heavyweight window and avoid clipping.

Note

setWindowTransparent on X11 doesn't composite entirely correctly; depending on what's drawn in the window it mey be more or less noticable.

Note

Neither shaped windows nor transparency currently works with Java 1.4 under X11. This is at least partly due to 1.4 using multiple X11 windows for a single given Java window. It *might* be possible to remedy by applying the window region/transparency to all descendants, but I haven't tried it. In addition, windows must be both displayable and visible before the corresponding native Drawable may be obtained; in later Java versions, the window need only be displayable.

Note

If you use setWindowMask(Window, Shape) and override Window#paint(Graphics) on OS X, you'll need to explicitly set the clip mask on the Graphics object with the window mask; only the content pane of the window and below have the window mask automatically applied.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
WindowUtils.HeavyweightForcer

This class forces a heavyweight popup on the parent Window.

private static class
WindowUtils.Holder

Canonical lazy loading of a singleton.

private static class
public abstract static class
WindowUtils.NativeWindowUtils

Window utilities with differing native implementations.

private abstract static class
WindowUtils.RepaintTrigger

This can be installed over a JLayeredPane in order to listen for repaint requests.

private static class
private static class

Field Summary

Modifier and TypeField and Description
public static boolean
public static final Shape
MASK_NONE

Use this to clear a window mask.

private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static GraphicsConfiguration
getAlphaCompatibleGraphicsConfiguration()

Returns a GraphicsConfiguration comptible with alpha compositing.

private static WindowUtils.NativeWindowUtils
public static boolean
isWindowAlphaSupported()

Indicate a window can have a global alpha setting.

public static void
setWindowAlpha(Window w, float alpha)

Set the overall window transparency.

public static void
setWindowMask(Window w, Shape mask)

Applies the given mask to the given window.

public static void
setWindowMask(Window w, Icon mask)

Applies the given mask to the given window.

public static void
setWindowTransparent(Window w, boolean transparent)

Set the window to be transparent.

public static void
whenDisplayable(Window w, final Runnable action)

Execute the given action when the given window becomes displayable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait