In order to achieve portable support of translucent applets dragged out of the browser, we need to add another hook,
public GraphicsConfiguration getDraggedAppletGraphicsConfiguration()
or similar, which will be called only on X11 platforms and which the applet can customize to decide which GraphicsConfiguration to use for the created Frame / JFrame. Here is sample code from ###@###.### for this purpose:
GraphicsConfiguration gc = null;
if (AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSLUCENT)) {
gc = findGraphicsConfig();
}
if (gc == null) {
// translucent windows are not supported
gc = // default config
}
JFrame = new JFrame(gc);
// and so on
private GraphicsConfiguration findGraphicsConfig() {
GraphicsDevice gd =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice();
GraphicsConfiguration gcs[] = gd.getConfigurations();
for (GraphicsConfiguration gc : gcs) {
if (AWTUtilities.isTranslucencyCapable(gc)) {
return gc;
}
}
return null;
}
public GraphicsConfiguration getDraggedAppletGraphicsConfiguration()
or similar, which will be called only on X11 platforms and which the applet can customize to decide which GraphicsConfiguration to use for the created Frame / JFrame. Here is sample code from ###@###.### for this purpose:
GraphicsConfiguration gc = null;
if (AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSLUCENT)) {
gc = findGraphicsConfig();
}
if (gc == null) {
// translucent windows are not supported
gc = // default config
}
JFrame = new JFrame(gc);
// and so on
private GraphicsConfiguration findGraphicsConfig() {
GraphicsDevice gd =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice();
GraphicsConfiguration gcs[] = gd.getConfigurations();
for (GraphicsConfiguration gc : gcs) {
if (AWTUtilities.isTranslucencyCapable(gc)) {
return gc;
}
}
return null;
}