001/* 002 * Copyright (c) 1999-2001 Keiron Liddle, Aftex Software 003 * 004 * This library is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License as published by the Free Software Foundation; either 007 * version 2.1 of the License, or (at your option) any later version. 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014*/ 015package com.aftexsw.ui; 016 017import java.awt.*; 018 019public class Util { 020 public static void centerFrame(Window inFrame) { 021 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 022 Dimension frameSize = inFrame.getSize(); 023 if (frameSize.height > screenSize.height) 024 frameSize.height = screenSize.height; 025 if (frameSize.width > screenSize.width) 026 frameSize.width = screenSize.width; 027 inFrame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); 028 } 029}