01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.comp;
25:
26: import jacareto.system.Environment;
27:
28: import java.awt.Component;
29: import java.awt.Window;
30:
31: /**
32: * This is a class which provides methods for Windows.
33: *
34: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
35: * @version 1.0
36: */
37: public class WindowHandler extends ContainerHandler {
38: /**
39: * Whether or not "window moved" and "window resized" events should be
40: * captured.
41: */
42: private boolean captureWindowMovedResized;
43:
44: /**
45: * Creates a new JFrame handler.
46: *
47: * @param env the environment
48: * @param components the components instance
49: */
50: public WindowHandler(Environment env, Components components) {
51: super (env, components);
52: captureWindowMovedResized = getCustomization().getBoolean(
53: "WindowMovingResizing.Capture", false);
54: }
55:
56: /**
57: * Returns whether this handler is responsible for the given component. This class is
58: * responsible for JFrames.
59: *
60: * @param component the component
61: *
62: * @return <code>true</code> if this handler is responsible for the given component, otherwise
63: * <code>false</code>
64: */
65: public boolean handlesComponent(Component component) {
66: return (component != null) && component instanceof Window;
67: }
68:
69: /**
70: * Things that should be done when a component has been added to the components instance.
71: *
72: * @param component the component
73: */
74: public void init(Component component) {
75: // Component events are only included for capturing "window moved" and "window resized"
76: // events. Because registering an event listener for all component events at the AWTEventQueue
77: // causes many problems (BlueJ hangs up, for example), component events are captured only
78: // for windows via the separate EventQueue of Jacareto.
79: if (captureWindowMovedResized) {
80: ((Window) component).addComponentListener(components
81: .getComponentListener());
82: }
83: }
84: }
|