Java tutorial
//package com.java2s; import java.awt.Dimension; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javax.swing.JDialog; public class Main { public static void ensureMinimumSize(JDialog dialog, Dimension size) { Dimension s = dialog.getSize(); Rectangle screen = availableScreenSize(); if (s.width <= screen.width * 0.15 || s.height <= screen.height * 0.15) { // if the window as dimension less than 15% in some direction // increase it if (size == null) { Dimension m = new Dimension((int) (screen.width * 0.625), (int) (screen.height * 0.708)); dialog.setSize(m); } else { Dimension m = new Dimension(Math.max(s.width, size.width), Math.max(s.height, size.height)); dialog.setSize(m); } } } /** * @return ScreenDimantions excluding toolbar */ public static Rectangle availableScreenSize() { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); // get maximum window bounds return graphicsEnvironment.getMaximumWindowBounds(); } }