throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows");
}
whenDisplayable(w, new Runnable() {
public void run() {
HWND hWnd = getHWnd(w);
User32 user = User32.INSTANCE;
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
byte level = (byte)((int)(255 * alpha) & 0xFF);
if (usingUpdateLayeredWindow(w)) {
// If already using UpdateLayeredWindow, continue to
// do so
BLENDFUNCTION blend = new BLENDFUNCTION();
blend.SourceConstantAlpha = level;
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
user.UpdateLayeredWindow(hWnd, null, null, null, null,
null, 0, blend,
WinUser.ULW_ALPHA);
}
else if (alpha == 1f) {
flags &= ~WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
}
else {
flags |= WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
user.SetLayeredWindowAttributes(hWnd, 0, level,
WinUser.LWA_ALPHA);
}
setForceHeavyweightPopups(w, alpha != 1f);
storeAlpha(w, level);
}