try to avoid not supporting translucent

This commit is contained in:
huangyuhui
2017-06-11 21:46:54 +08:00
parent 091898551e
commit cfa7b4832a
5 changed files with 21 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
@@ -182,10 +183,14 @@ public class TranslucentPopupFactory extends PopupFactory {
boolean isComboBoxPopup = (contents instanceof BasicComboPopup);
if (WindowTranslucencyHelper.isTranslucencySupported()) {
//每像素透明
WindowTranslucencyHelper.setWindowOpaque(w, false);
//内容组件半透明
w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f);
try {
//每像素透明
WindowTranslucencyHelper.setWindowOpaque(w, false);
//内容组件半透明
w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f);
} catch(Exception e) {
// ignore
}
}
// component.getContentPane().add(contents, BorderLayout.CENTER);

View File

@@ -27,7 +27,9 @@ public class WindowTranslucencyHelper {
* @return true, if is translucency supported
*/
public static boolean isTranslucencySupported() {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT);
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
return device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT) &&
device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT);
}
/**