Here you can find the source of modifyDimensions(Window window)
public static void modifyDimensions(Window window)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { public static void modifyDimensions(Window window) { if (window instanceof JFrame) { if (((JFrame) window).getExtendedState() == JFrame.MAXIMIZED_BOTH) { return; }/*from ww w. j ava 2 s. c o m*/ } Dimension result = window.getSize(); Dimension maxDimension = Toolkit.getDefaultToolkit().getScreenSize(); if (maxDimension.width < result.width) { result.width = maxDimension.width; } if (maxDimension.height < result.height) { result.height = maxDimension.height; } window.setSize(result); } }