KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > frame > WindowMaximizer


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18

19 /*
20  * Author: Hrk (Luca Santarelli) <hrk@users.sourceforge.net> Comments: this
21  * class provides some methods to enlarge or maximise a java.awt.Component
22  * object.
23  */

24 package org.columba.core.gui.frame;
25
26 //Resizing
27
import java.awt.Dimension JavaDoc;
28 import java.awt.Frame JavaDoc;
29 import java.awt.Toolkit JavaDoc;
30 import java.util.logging.Logger JavaDoc;
31
32 public class WindowMaximizer {
33     private static final Logger JavaDoc LOG = Logger
34             .getLogger("org.columba.core.gui.frame");
35
36     public static void maximize(Frame JavaDoc frame) {
37         //Can we use the Java way to maximize the window
38
if (Toolkit.getDefaultToolkit().isFrameStateSupported(
39                 Frame.MAXIMIZED_BOTH) == false) {
40             LOG.warning("System doesn't support maximize frame state.");
41             Dimension JavaDoc screenSize = Toolkit.getDefaultToolkit().getScreenSize();
42             frame.setSize(screenSize);
43         } else {
44             frame.setExtendedState(Frame.MAXIMIZED_BOTH);
45         }
46     }
47
48     public static boolean isWindowMaximized(Object JavaDoc obj) {
49         //We can use the Java way to maximize the window
50
Frame JavaDoc frame = (Frame JavaDoc) obj;
51         int state = frame.getExtendedState();
52
53         if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
54             return true;
55         }
56
57         return false;
58     }
59 };
60
Popular Tags