Java Utililty Methods Screen Size

List of utility methods to do Screen Size

Description

The list of methods to do Screen Size are organized into topic(s).

Method

voidsetWindowDesktopSize(Window window, double sizeX, double sizeY)
set Window Desktop Size
if (window == null) {
    throw new IllegalArgumentException("window == null");
if (sizeX < 0 || sizeX > 1)
    throw new IllegalArgumentException("size<0 | size>1");
if (sizeY < 0 || sizeY > 1)
    throw new IllegalArgumentException("size<0 | size>1");
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
...
voidsetWindowSize(final Window w, final Rectangle r)
set Window Size
final Toolkit kit = Toolkit.getDefaultToolkit();
final Dimension dim = kit.getScreenSize();
if (r.x < 0 || r.x > dim.width) {
    r.x = 0;
if (r.y < 0 || r.y > dim.height) {
    r.y = 0;
if (r.width < 50) {
    r.width = 50;
if (r.height < 50) {
    r.height = 50;
r.width = Math.min(r.width, (int) (dim.width * 0.99));
r.height = Math.min(r.height, (int) (dim.height * 0.99));
w.setBounds(r);
if (w instanceof Frame) {
    ((Frame) w).setState(0);
voidsizeForScreen(Component component)
size For Screen
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int maxHeight = (int) (screen.height * 0.9);
int maxWidth = Math.min(maxHeight, (int) (screen.width * 0.9));
component.setMaximumSize(new Dimension(maxWidth, maxHeight));
component.setPreferredSize(new Dimension(Math.min(800, maxWidth), Math.min(800, maxHeight)));