if (transparent == isTransparent) {
return;
}
whenDisplayable(w, new Runnable() {
public void run() {
User32 user = User32.INSTANCE;
HWND hWnd = getHWnd(w);
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
JRootPane root = ((RootPaneContainer)w).getRootPane();
JLayeredPane lp = root.getLayeredPane();
Container content = root.getContentPane();
if (content instanceof W32TransparentContentPane) {
((W32TransparentContentPane)content).setTransparent(transparent);
}
else if (transparent) {
W32TransparentContentPane w32content =
new W32TransparentContentPane(content);
root.setContentPane(w32content);
lp.add(new RepaintTrigger(w32content),
JLayeredPane.DRAG_LAYER);
}
if (transparent && !usingUpdateLayeredWindow(w)) {
flags |= User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
}
else if (!transparent && usingUpdateLayeredWindow(w)) {
flags &= ~User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
}
setLayersTransparent(w, transparent);
setForceHeavyweightPopups(w, transparent);
setDoubleBuffered(w, !transparent);
}