Here you can find the source of resizeAndCenter(JDialog dialog, double factor)
Parameter | Description |
---|---|
dialog | a parameter |
factor | a parameter |
public static void resizeAndCenter(JDialog dialog, double factor)
//package com.java2s; //License from project: LGPL import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; public class Main { /**/*from www . ja va2 s .com*/ * Resizes a {@link JDialog} by a given factor based on the client's screen * size. The screen is centered afterwards. * * @param dialog * @param factor */ public static void resizeAndCenter(JDialog dialog, double factor) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setSize((int) Math.round(screenSize.width * factor), (int) Math.round(screenSize.height * factor)); centerDialog(dialog); } /** * Centers the dialog on the screen. * * @param dialog */ public static void centerDialog(JDialog dialog) { dialog.setLocationRelativeTo(null); } }