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 isYOnScreen(int y) {
        GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        for (GraphicsDevice device : devices) {
            int boundA = device.getDefaultConfiguration().getBounds().y;
            int boundB = boundA + device.getDefaultConfiguration().getBounds().height;
            if (inBounds(y, 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;
    }
}