Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/robrohan/tools/FrameTools.java


1   /*
2    * Treebeard: an xml xslt transfomer
3    * Copyright (C) 2002 Rob Rohan
4    * This program is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU General Public License as published by the
6    * Free Software Foundation; either version 2 of the License, or (at your
7    * option) any later version.
8    * 
9    * This program is distributed in the hope that it will be useful, but 
10   * WITHOUT ANY WARRANTY; without even the implied warranty of 
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
12   * General Public License for more details.
13   * 
14   * You should have received a copy of the GNU General Public License along 
15   * with this program; if not, write to the Free Software Foundation, Inc.,
16   * 675 Mass Ave, Cambridge, MA 02139, USA.
17   *
18   * Email: me@robrohan.com
19   * 
20   * Thanks to Ian F. Darwin (Java Cookbook) for code example
21   *
22   * FrameTools.java
23   * 
24   * Created on April 17, 2002, 3:49 PM
25   */
26  
27  /**
28   * Misc Frame tools
29   * @author  robrohan
30   */
31  package com.robrohan.tools;
32  
33  /** Common tools used in frames
34   */
35  public class FrameTools {
36      
37      /** Creates a new instance of FrameTools */
38      public FrameTools(){;}
39  
40      /** Center a frame on the screen
41       * @param frame the frame to center
42       */    
43      public static void center(java.awt.Window frame){
44          /**
45           * centers a frame in the middle of the screen
46           **/
47          java.awt.Dimension bounds = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
48          java.awt.Dimension fbounds = frame.getSize(); 
49          frame.setLocation(    
50              (bounds.width - fbounds.width) / 2, 
51              (bounds.height - fbounds.height) / 2); 
52       } 
53  }