01: /*
02: * SwingML Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Ezequiel Cuellar <ecuellar@crosslogic.com>
19: *
20: */
21:
22: package org.swingml.view.renderer;
23:
24: import java.awt.*;
25: import java.awt.event.*;
26:
27: import org.swingml.*;
28: import org.swingml.component.*;
29: import org.swingml.event.*;
30: import org.swingml.model.*;
31: import org.swingml.view.*;
32:
33: public class JFrameRenderer extends RendererUtil implements Renderer {
34:
35: private void applyMaximize(JFrameComponent theFrame,
36: JFrameModel theModel) {
37: if (theModel.isMaximize()) {
38: theFrame.setState(JFrameComponent.MAXIMIZED_BOTH);
39: }
40: }
41:
42: private void applyXYStartPosition(JFrameComponent theFrame,
43: JFrameModel theModel) {
44: if (theModel.getXOpen() > -1 && theModel.getYOpen() > -1) {
45: theFrame.setLocation(theModel.getXOpen(), theModel
46: .getYOpen());
47: }
48: }
49:
50: public Container render(AbstractSwingMLModel aModel,
51: Container aParent) {
52: JFrameModel theModel = (JFrameModel) aModel;
53: JFrameComponent theFrame = new JFrameComponent(theModel);
54: theFrame.setLocationRelativeTo(aParent);
55: theFrame.setOwner(aParent);
56: applyXYStartPosition(theFrame, theModel);
57: applyMaximize(theFrame, theModel);
58: theFrame.addWindowListener(aModel);
59: theFrame.addWindowListener(new WindowListener() {
60:
61: public void windowActivated(WindowEvent e) {
62: }
63:
64: public void windowClosed(WindowEvent e) {
65: WindowNotificationRegistrar.sole().windowRemoved(
66: e.getWindow());
67: }
68:
69: public void windowClosing(WindowEvent e) {
70: WindowNotificationRegistrar.sole().windowRemoved(
71: e.getWindow());
72: }
73:
74: public void windowDeactivated(WindowEvent e) {
75: }
76:
77: public void windowDeiconified(WindowEvent e) {
78: }
79:
80: public void windowIconified(WindowEvent e) {
81: }
82:
83: public void windowOpened(WindowEvent e) {
84: }
85: });
86: super .iterate(theModel, theFrame.getContentPane());
87: WindowNotificationRegistrar.sole().windowAdded(theFrame);
88: theFrame.setVisible(true);
89:
90: return theFrame;
91: }
92: }
|