Java Code Examples for java.awt.GraphicsDevice#isWindowTranslucencySupported()

The following examples show how to use java.awt.GraphicsDevice#isWindowTranslucencySupported() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslucentShapedFrameTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 2
Source File: SwingUtils.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public static boolean isTranslucentSupported() {
	GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsDevice gd = ge.getDefaultScreenDevice();

	boolean isUniformTranslucencySupported = gd
			.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT);
	return isUniformTranslucencySupported;
}
 
Example 3
Source File: TranslucentShapedFrameTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 4
Source File: TranslucentShapedFrameTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 5
Source File: TranslucentShapedFrameTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 6
Source File: TranslucentShapedFrameTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 7
Source File: TranslucentShapedFrameTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 8
Source File: TranslucentShapedFrameTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 9
Source File: TranslucentShapedFrameTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 10
Source File: TranslucentShapedFrameTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 11
Source File: TranslucentShapedFrameTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 12
Source File: NoNativeAccessWindowSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setWindowMask(Window w, Shape mask) {
    GraphicsConfiguration gc = w.getGraphicsConfiguration();
    GraphicsDevice gd = gc.getDevice();
    if (gc.getDevice().getFullScreenWindow() == w) {
        return;
    }
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        return;
    }
    w.setShape(mask);
}
 
Example 13
Source File: NoNativeAccessWindowSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setWindowAlpha(Window w, float alpha) {
    GraphicsConfiguration gc = w.getGraphicsConfiguration();
    GraphicsDevice gd = gc.getDevice();
    if (gc.getDevice().getFullScreenWindow() == w) {
        return;
    }
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        return;
    }
    w.setOpacity(alpha);
}
 
Example 14
Source File: TranslucentShapedFrameTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 15
Source File: TranslucentShapedFrameTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 16
Source File: TranslucentShapedFrameTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkEffects() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        shapedCb.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
        transparencySld.setEnabled(false);
    }
    if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        nonOpaqueChb.setEnabled(false);
    }
}
 
Example 17
Source File: TransparencyTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsDevice.WindowTranslucency mode = GraphicsDevice.WindowTranslucency.TRANSLUCENT;
        boolean translucencyCheck = gd.isWindowTranslucencySupported(mode);
        if(!translucencyCheck) {
            return;
    }

        Robot robot = new Robot();
        // create a GUI
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });
        robot.waitForIdle();
        Color opaque = robot.getPixelColor(dlgPos.x + 100, dlgPos.y + 100);

        // set Dialog Opacity
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                dialog.setOpacity(OPACITY);
            }
        });
        robot.waitForIdle();

        // iconify frame
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                frame.setExtendedState(JFrame.ICONIFIED);
            }
        });
        robot.waitForIdle();

        // deiconify frame
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                frame.setExtendedState(JFrame.NORMAL);
            }
        });
        robot.waitForIdle();

        Color transparent = robot.getPixelColor(dlgPos.x + 100, dlgPos.y + 100);
        if (transparent.equals(opaque)) {
            frame.dispose();
            throw new RuntimeException("JDialog transparency lost "
                    + "upon iconify/deiconify sequence");
        }
        frame.dispose();
    }
 
Example 18
Source File: BubbleWindow.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates an instance with the given parameters. Should be called with the arguments gathered
 * from {@link BubbleWindowBuilder} implementations.
 *
 * @param owner
 *            the {@link Window} on which this {@link BubbleWindow} should be shown
 * @param style
 *            the style the bubble should have
 * @param preferredAlignment
 *            offer for alignment but the Class will calculate by itself whether the position is
 *            usable
 * @param i18nKey
 *            key of the message which should be shown
 * @param docKey
 *            key of the Dockable the BubbleWindow will attach to
 * @param moveable
 *            if {@code true} the user can drag the bubble around on screen
 * @param showCloseButton
 *            if {@code true} the user can close the bubble via an "x" button in the top right
 *            corner
 * @param titleFont
 *            the font for the title, can be {@code null}
 * @param bodyFont
 *            the font for the body, can be {@code null}
 * @param componentsToAdd
 *            Array of {@link JComponent}s which will be added to the Bubble (null instead of
 *            the array won't throw an error)
 * @param arguments
 *            arguments to pass thought to the I18N Object
 */
protected BubbleWindow(final Window owner, final BubbleStyle style, final AlignedSide preferredAlignment,
		final String i18nKey, final String docKey, final Font titleFont, final Font bodyFont, final boolean moveable,
		final boolean showCloseButton, final JComponent[] componentsToAdd, final Object... arguments) {
	super(owner);

	// if this check fails, the bubbles will look very ugly, but we can't change that I guess
	GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsDevice gd = ge.getDefaultScreenDevice();
	isPerPixelTranslucencySupported = gd
			.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT);
	if (!isPerPixelTranslucencySupported) {
		LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.tools.bubble.BubbleWindow.per_pixel_not_supported");
	}

	this.i18nKey = i18nKey;
	this.arguments = arguments;
	this.myPerspective = getCurrentPerspectiveName();
	this.preferredAlignment = preferredAlignment;
	this.moveable = moveable;
	if (docKey != null) {
		this.docKey = docKey;
		dockable = desktop.getContext().getDockableByKey(docKey);
	}

	this.style = style;
	if (titleFont != null) {
		this.titleFont = titleFont;
	} else {
		this.titleFont = style.getTitleFont();
	}
	if (bodyFont != null) {
		this.bodyFont = bodyFont;
	} else {
		this.bodyFont = style.getBodyFont();
	}
	this.showCloseButton = showCloseButton;
	if (componentsToAdd == null) {
		componentsInBubble = new JComponent[] {};
	} else {
		componentsInBubble = componentsToAdd;
	}
}
 
Example 19
Source File: Toast.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
private void initComponents() {
    setLayout(new FlowLayout(FlowLayout.CENTER));
    addComponentListener(new ComponentAdapter() {
        // Give the window an rounded rect shape.
 
        @Override
        public void componentResized(ComponentEvent e) {
            setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 30, 30));
        }
    });
    setUndecorated(true);
    setSize(300, 50);
    setLocationRelativeTo(frame);// adding toast to frame or use null
    getContentPane().setBackground(Color.BLACK);
     
    // Determine what the GraphicsDevice can support.
    GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    final boolean isTranslucencySupported =
            gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT);
 
    //If shaped windows aren't supported, exit.
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        System.err.println("Shaped windows are not supported");
    }
 
    //If translucent windows are supported, 
    //create an opaque window.
    // Set the window to 50% translucency, if supported.
    if (isTranslucencySupported) {
        setOpacity(0.5f);
    } else {
        System.out.println("Translucency is not supported.");
    }
 
    JLabel label = new JLabel();
    label.setForeground(Color.WHITE);
    label.setText(msg);
    add(label);
}
 
Example 20
Source File: Toast.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
private void initComponents() {
    setLayout(new FlowLayout(FlowLayout.CENTER));
    addComponentListener(new ComponentAdapter() {
        // Give the window an rounded rect shape.
 
        @Override
        public void componentResized(ComponentEvent e) {
            setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 30, 30));
        }
    });
    setUndecorated(true);
    setSize(300, 50);
    setLocationRelativeTo(frame);// adding toast to frame or use null
    getContentPane().setBackground(Color.BLACK);
     
    // Determine what the GraphicsDevice can support.
    GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    final boolean isTranslucencySupported =
            gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT);
 
    //If shaped windows aren't supported, exit.
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) {
        System.err.println("Shaped windows are not supported");
    }
 
    //If translucent windows are supported, 
    //create an opaque window.
    // Set the window to 50% translucency, if supported.
    if (isTranslucencySupported) {
        setOpacity(0.5f);
    } else {
        System.out.println("Translucency is not supported.");
    }
 
    JLabel label = new JLabel();
    label.setForeground(Color.WHITE);
    label.setText(msg);
    add(label);
}