01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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;
28: import java.awt.Frame;
29: import java.awt.Toolkit;
30: import java.util.logging.Logger;
31:
32: public class WindowMaximizer {
33: private static final Logger LOG = Logger
34: .getLogger("org.columba.core.gui.frame");
35:
36: public static void maximize(Frame 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 screenSize = Toolkit.getDefaultToolkit()
42: .getScreenSize();
43: frame.setSize(screenSize);
44: } else {
45: frame.setExtendedState(Frame.MAXIMIZED_BOTH);
46: }
47: }
48:
49: public static boolean isWindowMaximized(Object obj) {
50: //We can use the Java way to maximize the window
51: Frame frame = (Frame) obj;
52: int state = frame.getExtendedState();
53:
54: if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
55: return true;
56: }
57:
58: return false;
59: }
60: };
|