Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Main {
    public static boolean isXOnScreen(int x) {
        GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        for (GraphicsDevice device : devices) {
            int boundA = device.getDefaultConfiguration().getBounds().x;
            int boundB = boundA + device.getDefaultConfiguration().getBounds().width;
            if (inBounds(x, boundA, boundB)) {
                return true;
            }
        }
        return false;
    }

    private static boolean inBounds(int x, int boundA, int boundB) {
        if (boundA < boundB) {
            return x >= boundA && x <= boundB;
        }
        return x <= boundA && x >= boundB;
    }
}