001/**
002 * WindowUtils.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 24/10/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.method.gui.utils;
010
011import java.awt.Dimension;
012
013import javax.swing.JDialog;
014import javax.swing.JFrame;
015
016/**
017 * Utility class to manage windows
018 * @author Juan A. Recio-Garcia
019 * @version 1.0
020 *
021 */
022public class WindowUtils
023{
024
025    public static void centerWindow(JFrame frame)
026    {
027        Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
028        frame.setBounds((screenSize.width - frame.getWidth()) / 2,
029                (screenSize.height - frame.getHeight()) / 2, 
030                frame.getWidth(),
031                frame.getHeight());
032    }
033    public static void centerWindow(JDialog dialog)
034    {
035        Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
036        dialog.setBounds((screenSize.width - dialog.getWidth()) / 2,
037                (screenSize.height - dialog.getHeight()) / 2, 
038                dialog.getWidth(),
039                dialog.getHeight());
040    }
041}