Java Code Examples for java.awt.Robot#getPixelColor()

The following examples show how to use java.awt.Robot#getPixelColor() . 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 openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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 jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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: MultiResolutionSplashTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 4
Source File: PaintNativeOnUpdate.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 5
Source File: PaintNativeOnUpdate.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 6
Source File: PressedIconTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(() -> createAndShowGUI());
    robot.waitForIdle();

    SwingUtilities.invokeAndWait(() -> {
        scale = frame.getGraphicsConfiguration().getDefaultTransform()
                .getScaleX();
        Point location = frame.getLocation();
        Dimension size = frame.getSize();
        centerX = location.x + size.width / 2;
        centerY = location.y + size.height / 2;
    });
    robot.waitForIdle();

    robot.mouseMove(centerX, centerY);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.waitForIdle();
    Thread.sleep(100);
    Color color = robot.getPixelColor(centerX, centerY);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    SwingUtilities.invokeAndWait(() -> frame.dispose());

    if ((scale == 1 && !similar(color, COLOR_1X))
            || (scale == 2 && !similar(color, COLOR_2X))) {
        throw new RuntimeException("Colors are different!");
    }
}
 
Example 7
Source File: PaintNativeOnUpdate.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 8
Source File: MultiResolutionSplashTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 9
Source File: PaintNativeOnUpdate.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 10
Source File: ModalDialogOrderingTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 11
Source File: ModalDialogOrderingTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 12
Source File: PaintNativeOnUpdate.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 13
Source File: MultiResolutionSplashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();
    if (splashBounds.width != IMAGE_WIDTH) {
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if (splashBounds.height != IMAGE_HEIGHT) {
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);
    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example 14
Source File: bug8016356.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // Windows only test
        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {

            // Retrieving top edge of Desktop
            GraphicsConfiguration grConf = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();
            Rectangle scrRect = grConf.getBounds();
            Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
            scrTop = scrRect.y + scrInsets.top;

            color = new Color(0, 255, 0);

            SwingUtilities.invokeAndWait(() -> {
                createAndShowUI();
            });

            try {
                Robot robot = new Robot();
                robot.setAutoDelay(500);
                robot.setAutoWaitForIdle(true);
                robot.delay(1000);

                // Resizing a window to invoke Windows Snap feature
                readFrameInfo();
                robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);

                // Retrieving the color of window expanded area
                readFrameInfo();
                Insets insets = frame.getInsets();
                Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2,
                        frLoc.y + frSize.height - insets.bottom - 1);

                frame.dispose();

                if (!bgColor.equals(color)) {
                    throw new RuntimeException("TEST FAILED: got "
                            + bgColor + " instead of " + color);
                }
                System.out.println("TEST PASSED!");
            } catch (AWTException ex) {
                throw new RuntimeException("TEST FAILED!");
            }
        }
    }
 
Example 15
Source File: bug8016356.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // Windows only test
        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {

            // Retrieving top edge of Desktop
            GraphicsConfiguration grConf = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();
            Rectangle scrRect = grConf.getBounds();
            Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
            scrTop = scrRect.y + scrInsets.top;

            color = new Color(0, 255, 0);

            SwingUtilities.invokeAndWait(() -> {
                createAndShowUI();
            });

            try {
                Robot robot = new Robot();
                robot.setAutoDelay(500);
                robot.setAutoWaitForIdle(true);
                robot.delay(1000);

                // Resizing a window to invoke Windows Snap feature
                readFrameInfo();
                robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);

                // Retrieving the color of window expanded area
                readFrameInfo();
                Insets insets = frame.getInsets();
                Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2,
                        frLoc.y + frSize.height - insets.bottom - 1);

                frame.dispose();

                if (!bgColor.equals(color)) {
                    throw new RuntimeException("TEST FAILED: got "
                            + bgColor + " instead of " + color);
                }
                System.out.println("TEST PASSED!");
            } catch (AWTException ex) {
                throw new RuntimeException("TEST FAILED!");
            }
        }
    }
 
Example 16
Source File: bug8016356.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // Windows only test
        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {

            // Retrieving top edge of Desktop
            GraphicsConfiguration grConf = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();
            Rectangle scrRect = grConf.getBounds();
            Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
            scrTop = scrRect.y + scrInsets.top;

            color = new Color(0, 255, 0);

            SwingUtilities.invokeAndWait(() -> {
                createAndShowUI();
            });

            try {
                Robot robot = new Robot();
                robot.setAutoDelay(500);
                robot.setAutoWaitForIdle(true);
                robot.delay(1000);

                // Resizing a window to invoke Windows Snap feature
                readFrameInfo();
                robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);

                // Retrieving the color of window expanded area
                readFrameInfo();
                Insets insets = frame.getInsets();
                Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2,
                        frLoc.y + frSize.height - insets.bottom - 1);

                frame.dispose();

                if (!bgColor.equals(color)) {
                    throw new RuntimeException("TEST FAILED: got "
                            + bgColor + " instead of " + color);
                }
                System.out.println("TEST PASSED!");
            } catch (AWTException ex) {
                throw new RuntimeException("TEST FAILED!");
            }
        }
    }
 
Example 17
Source File: bug8016356.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 {

        // Windows only test
        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {

            // Retrieving top edge of Desktop
            GraphicsConfiguration grConf = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();
            Rectangle scrRect = grConf.getBounds();
            Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
            scrTop = scrRect.y + scrInsets.top;

            color = new Color(0, 255, 0);

            SwingUtilities.invokeAndWait(() -> {
                createAndShowUI();
            });

            try {
                Robot robot = new Robot();
                robot.setAutoDelay(500);
                robot.setAutoWaitForIdle(true);
                robot.delay(1000);

                // Resizing a window to invoke Windows Snap feature
                readFrameInfo();
                robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);

                // Retrieving the color of window expanded area
                readFrameInfo();
                Insets insets = frame.getInsets();
                Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2,
                        frLoc.y + frSize.height - insets.bottom - 1);

                frame.dispose();

                if (!bgColor.equals(color)) {
                    throw new RuntimeException("TEST FAILED: got "
                            + bgColor + " instead of " + color);
                }
                System.out.println("TEST PASSED!");
            } catch (AWTException ex) {
                throw new RuntimeException("TEST FAILED!");
            }
        }
    }
 
Example 18
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Tests whether screen pixel has the expected color performing several
 * attempts. This method is useful for asynchronous window manager where
 * it's impossible to determine when drawing actually takes place.
 *
 * @param x X position of pixel
 * @param y Y position of pixel
 * @param color expected color
 * @param attempts number of attempts to undertake
 * @param delay delay before each attempt
 * @param robot a robot to use for retrieving pixel color
 * @return true if pixel color matches the color expected, otherwise false
 */
public static boolean testPixelColor(int x, int y, final Color color, int attempts, int delay, final Robot robot) {
    while (attempts-- > 0) {
        robot.delay(delay);
        Color screen = robot.getPixelColor(x, y);
        if (screen.equals(color)) {
            return true;
        }
    }
    return false;
}
 
Example 19
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Tests whether screen pixel has the expected color performing several
 * attempts. This method is useful for asynchronous window manager where
 * it's impossible to determine when drawing actually takes place.
 *
 * @param x X position of pixel
 * @param y Y position of pixel
 * @param color expected color
 * @param attempts number of attempts to undertake
 * @param delay delay before each attempt
 * @param robot a robot to use for retrieving pixel color
 * @return true if pixel color matches the color expected, otherwise false
 */
public static boolean testPixelColor(int x, int y, final Color color, int attempts, int delay, final Robot robot) {
    while (attempts-- > 0) {
        robot.delay(delay);
        Color screen = robot.getPixelColor(x, y);
        if (screen.equals(color)) {
            return true;
        }
    }
    return false;
}
 
Example 20
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Tests whether screen pixel has the expected color performing several
 * attempts. This method is useful for asynchronous window manager where
 * it's impossible to determine when drawing actually takes place.
 *
 * @param x X position of pixel
 * @param y Y position of pixel
 * @param color expected color
 * @param attempts number of attempts to undertake
 * @param delay delay before each attempt
 * @param robot a robot to use for retrieving pixel color
 * @return true if pixel color matches the color expected, otherwise false
 */
public static boolean testPixelColor(int x, int y, final Color color, int attempts, int delay, final Robot robot) {
    while (attempts-- > 0) {
        robot.delay(delay);
        Color screen = robot.getPixelColor(x, y);
        if (screen.equals(color)) {
            return true;
        }
    }
    return false;
}