Java Code Examples for java.awt.Window#setBackground()
The following examples show how to use
java.awt.Window#setBackground() .
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: BackgroundIsNotUpdated.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 2
Source File: BackgroundIsNotUpdated.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 3
Source File: BackgroundIsNotUpdated.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 4
Source File: BackgroundIsNotUpdated.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 5
Source File: BackgroundIsNotUpdated.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 6
Source File: BackgroundIsNotUpdated.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 7
Source File: BackgroundIsNotUpdated.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 8
Source File: BackgroundIsNotUpdated.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 9
Source File: OfficialApi.java From 07kit with GNU General Public License v3.0 | 5 votes |
public void setWindowOpaque(Window window, boolean isOpaque) { // prevent setting if not supported if(!isTranslucencyCapable(window.getGraphicsConfiguration()) || !isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT, window.getGraphicsConfiguration().getDevice())) { return; } final Color background = window.getBackground(); final int alpha = isOpaque ? OPAQUE : NOT_OPAQUE; window.setBackground(new Color(background.getRed(), background.getGreen(), background.getBlue(), alpha)); }
Example 10
Source File: FullScreenInsets.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 11
Source File: FullScreenInsets.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 12
Source File: FullScreenInsets.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 13
Source File: FullScreenInsets.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 14
Source File: FullScreenInsets.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 15
Source File: FullScreenInsets.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 16
Source File: FullScreenInsets.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 17
Source File: FullScreenInsets.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 18
Source File: FullScreenInsets.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 19
Source File: FullScreenInsets.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 20
Source File: WindowUtils.java From seaglass with Apache License 2.0 | 3 votes |
/** * Tries to make the given {@link Window} non-opqaue (transparent) across * platforms and JREs. This method is not guaranteed to succeed, and will * fail silently if the given {@code Window} cannot be made non-opaque. * * <p>This method is useful, for example, when creating a HUD style window * that is semi-transparent, and thus doesn't want the window background to * be drawn.</p> * * @param window the {@code Window} to make non-opaque. */ public static void makeWindowNonOpaque(Window window) { if (PlatformUtils.isJava6()) { // on non-mac platforms, try to use the facilities of Java 6 update 10. if (!PlatformUtils.isMac()) { quietlyTryToMakeWindowNonOqaque(window); } else { window.setBackground(UIManager.getColor("seaGlassTransparent")); } } }