Here you can find the source of setWindowSize(final Window w, final Rectangle r)
public static void setWindowSize(final Window w, final Rectangle r)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Frame; import java.awt.Toolkit; import java.awt.Rectangle; import java.awt.Window; public class Main { public static void setWindowSize(final Window w, final Rectangle r) { final Toolkit kit = Toolkit.getDefaultToolkit(); final Dimension dim = kit.getScreenSize(); if (r.x < 0 || r.x > dim.width) { r.x = 0;/* www. ja va2 s . c o m*/ } 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); } } }