1 package com.darwinsys.util;
   2 
   3 import java.awt.*;
   4 
   5 /** Utilities for GUI work.
   6  * @version $Id: UtilGUI.java,v 1.3 2001/12/26 01:04:07 ian Exp $
   7  */
   8 public class UtilGUI {
   9   /** Centre a Window, Frame, JFrame, Dialog, etc. */
  10   public static void centre(Window w) {
  11     // After packing a Frame or Dialog, centre it on the screen.
  12     Dimension us = w.getSize();
  13     Dimension them = Toolkit.getDefaultToolkit().getScreenSize();
  14     int newX = (them.width - us.width) / 2;
  15     int newY = (them.height - us.height) / 2;
  16     w.setLocation(newX, newY);
  17   }
  18 
  19   /** Center a Window, Frame, JFrame, Dialog, etc.,
  20    * but do it the American Spelling Way :-)
  21    */
  22   public static void center(Window w) {
  23     UtilGUI.centre(w);
  24   }
  25 
  26   /** Maximize a window, the hard way. */
  27   public static void maximize(Window w) {
  28     Dimension them = Toolkit.getDefaultToolkit().getScreenSize();
  29     w.setBounds(0, 0, them.width, them.height);
  30   }
  31 }


CategoryJava

ZbmonWiki: UtilGUI.java (2005-11-07 13:41:15에 zbmon가(이) 마지막으로 수정)