Here you can find the source of isInsideScreen(JDialog component)
Parameter | Description |
---|---|
component | - JDialog component which position is checked |
public static boolean isInsideScreen(JDialog component)
//package com.java2s; //License from project: Open Source License import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javax.swing.JDialog; public class Main { /**/* www. j a v a2 s . c o m*/ * Checks if component is inside the screen bounds * @param component - JDialog component which position is checked * @return true if component inside the screen bounds, false otherwise */ public static boolean isInsideScreen(JDialog component) { boolean inside; Rectangle virtualBounds = getVirtualBounds(); inside = virtualBounds.contains(component.getBounds()); return inside; } /** * Returns the screen bounds. * @return bounds of the screen */ public static Rectangle getVirtualBounds() { Rectangle bounds = new Rectangle(0, 0, 0, 0); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice lstGDs[] = ge.getScreenDevices(); for (GraphicsDevice gd : lstGDs) { bounds.add(gd.getDefaultConfiguration().getBounds()); } return bounds; } }