Here you can find the source of fitToDesktop(final JFrame frame)
Parameter | Description |
---|---|
frame | a parameter |
public static void fitToDesktop(final JFrame frame)
//package com.java2s; /**/* www.ja va2s .c om*/ * <p> * This class contains useful methods for positioning, sizing, and manipulating JFrames and other * Window-like elements. * </p> * <p> * <span class="BSDLicense"> This software is distributed under the <a * href="http://hci.stanford.edu/research/copyright.txt">BSD License</a>. </span> * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ import java.awt.*; import javax.swing.JFrame; public class Main { private static Rectangle desktopBounds = new Rectangle(0, 0, 640, 480); /** * @param frame * * @created Feb 16, 2006 * @author Ron Yeh */ public static void fitToDesktop(final JFrame frame) { final int minWidth = (int) Math.min(frame.getBounds().getWidth(), desktopBounds.getWidth()); final int minHeight = (int) Math.min(frame.getBounds().getHeight(), desktopBounds.getHeight()); frame.setSize(minWidth, minHeight); } }