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: Robert J. Morris <robertj@morris.net>
19: *
20: */
21:
22: package org.swingml.view.renderer;
23:
24: import java.awt.*;
25:
26: import javax.swing.*;
27:
28: import org.swingml.*;
29: import org.swingml.component.*;
30: import org.swingml.model.*;
31: import org.swingml.view.*;
32: import org.swingml.view.Renderer;
33:
34: public class JPanelRenderer extends RendererUtil implements Renderer {
35:
36: public Container render(AbstractSwingMLModel aModel,
37: Container aParent) {
38: JPanelModel theModel = (JPanelModel) aModel;
39: JPanelComponent panel = new JPanelComponent(theModel);
40: String orientation = theModel.getOrientation();
41: if (orientation != null && !(aParent instanceof JTabbedPane)) {
42: aParent.add(panel, orientation);
43: } else if (aParent instanceof JTabbedPane) {
44: JTabbedPane theTabbedPane = (JTabbedPane) aParent;
45: theTabbedPane.add(theModel.getText(), panel);
46: } else if (aParent instanceof JScrollPane) {
47: JScrollPane sp = (JScrollPane) aParent;
48: sp.setViewportView(panel);
49: } else {
50: aParent.add(panel);
51: }
52: super .iterate(theModel, panel.getBodyPanel());
53:
54: if (theModel.getWindowTitle() != null) {
55: JFrameComponent aFrame = SwingMLComponentUtilities
56: .getJFrameComponent(aParent);
57: if (aFrame != null)
58: aFrame.setTitle(theModel.getWindowTitle());
59: }
60:
61: return panel;
62:
63: }
64: }
|