View Javadoc

1   /*
2    * This file is part of NetPisteur.
3    * 
4    * Copyright 2007 : Damien RAUDE-MORVAN
5    * 
6    * NetPisteur is free software; you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation; either version 2 of the License, or
9    * (at your option) any later version.
10   *
11   * NetPisteur is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with NetPisteur; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19   *
20   */
21  package com.drazzib.netpisteur.util;
22  
23  import java.awt.Frame;
24  import java.awt.GraphicsConfiguration;
25  import java.awt.GraphicsEnvironment;
26  import java.awt.Rectangle;
27  
28  import org.apache.commons.logging.Log;
29  import org.apache.commons.logging.LogFactory;
30  
31  public class SwingUtils {
32  	
33  	private static Log log = LogFactory.getLog(SwingUtils.class);
34  
35  	/**
36  	 * Permet de maximiser la fenetre auto et d'tre sr qu'elle ne dpasse pas
37  	 * les capacits d'affichage de l'cran (rsolution) Maximise
38  	 * 
39  	 * @param frame
40  	 *            Frame
41  	 */
42  	public static void maxFrame(Frame frame) {
43  		GraphicsConfiguration gc = GraphicsEnvironment
44  				.getLocalGraphicsEnvironment().getDefaultScreenDevice()
45  				.getDefaultConfiguration();
46  		Rectangle ct;
47  
48  		try {
49  			ct = gc.getBounds();
50  			frame.setSize(ct.width - 75, ct.height - 75);
51  		} catch (NoSuchMethodError e) {
52  			// ATTENTION : Pas de methode getBounds() dans JDK < 1.3
53  			log.warn("Erreur de maximisation fenetre");
54  			frame.setSize(800, 600);
55  		}
56  	}
57  
58  }