Here you can find the source of setSize(JDialog dialog, int width, int height)
Parameter | Description |
---|---|
dialog | dialog to be sized |
width | wanted width |
height | wanted height |
public static void setSize(JDialog dialog, int width, int height)
//package com.java2s; /*//from www .ja va 2s. c o m * TV-Browser * Copyright (C) 04-2003 Martin Oberhauser (martin_oat@yahoo.de) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * CVS information: * $RCSfile$ * $Source$ * $Date: 2010-11-14 17:44:44 +0100 (Sun, 14 Nov 2010) $ * $Author: bananeweizen $ * $Revision: 6823 $ */ import java.awt.Dimension; import javax.swing.JDialog; public class Main { /** * set the size of a dialog, but never sizes it smaller than the preferred * size * * @param dialog * dialog to be sized * @param width * wanted width * @param height * wanted height */ public static void setSize(JDialog dialog, int width, int height) { dialog.pack(); Dimension size = dialog.getMinimumSize(); if (width > size.width) { size.width = width; } if (height > size.height) { size.height = height; } dialog.setSize(size); } }