001: /*
002: * Javu WingS - Lightweight Java Component Set
003: * Copyright (c) 2005-2007 Krzysztof A. Sadlocha
004: * e-mail: ksadlocha@programics.com
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020:
021: package com.javujavu.javux.wings;
022:
023: import java.awt.BorderLayout;
024: import java.awt.Frame;
025: import java.awt.Graphics;
026: import java.awt.Insets;
027: import java.awt.Window;
028:
029: /**
030: * An extended version of <code>java.awt.Window</code> that adds support for
031: * the WingS component architecture.
032: * <code>WingWindow</code> contains a
033: * <code>WingRootPane</code> as its only child.<br>
034: * <br>
035: * <b>This is one of the core WingS classes required by all the components</b><br>
036: * <br>
037: * <b>This class is thread safe.</b>
038: * @see WingRootPane
039: **/
040: public class WingWindow extends Window {
041: protected/*final*/WingRootPane root;
042: private static Frame dummyFrame;
043:
044: protected static Frame getDummyFrame() {
045: if (dummyFrame == null)
046: dummyFrame = new Frame();
047: return dummyFrame;
048: }
049:
050: /**
051: * Constructs an initially invisible <code>Window</code>
052: */
053: public WingWindow() {
054: this (getDummyFrame());
055: }
056:
057: /**
058: * Constructs an initially invisible <code>Window</code> with
059: * the specified owner <code>Frame</code>.
060: *
061: * @param owner the owner of the window
062: */
063: public WingWindow(Frame owner) {
064: super (owner);
065: root = new WingRootPane();
066: this .add(root, BorderLayout.CENTER);
067: }
068:
069: /**
070: * Returns the rootPane object for this dialog.
071: * @see WingRootPane
072: */
073: public WingRootPane getRootPane() {
074: return root;
075: }
076:
077: /**
078: * Sets the contentPane for this dialog.
079: * @see WingRootPane#setContentPane(WingComponent)
080: * @param c the new content pane
081: */
082: public void setContentPane(WingComponent c) {
083: root.setContentPane(c);
084: }
085:
086: /**
087: * Sets the menu bar for this dialog.
088: * @param c the menu bar being placed in the dialog
089: */
090: public void setMenuBar(WingComponent c) {
091: root.setMenuBar(c);
092: }
093:
094: public void update(Graphics g) {
095: paint(g);
096: }
097:
098: public void paint(Graphics g) {
099: Insets insets = getInsets();
100: g.translate(insets.left, insets.top);
101: root.paint(g);
102: }
103: }
|