001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets;
006:
007: import java.awt.*;
008: import java.awt.event.*;
009: import java.io.*;
010: import java.util.*;
011:
012: import com.javelin.swinglets.plaf.*;
013: import com.javelin.swinglets.theme.*;
014: import com.javelin.swinglets.event.*;
015:
016: /**
017: * A InternalFrame is a page that behaves like a Frame within
018: * a Frame.
019: *
020: * @author Robin Sharp
021: */
022:
023: public class SInternalFrame extends SContainer {
024: /**
025: * Construct a fully qualified SInternalFrame.
026: */
027: public SInternalFrame() {
028: }
029:
030: /**
031: * Returns the name of the L&F class that renders this component.
032: */
033: public Class getUIClass() {
034: return SInternalFrame.class;
035: }
036:
037: /**
038: * Set that this SInternalFrame can be closed by some user action.
039: */
040: public SInternalFrame setCloseable(boolean closeable) {
041: firePropertyChange("closeable", this .closeable,
042: this .closeable = closeable);
043: return this ;
044: }
045:
046: /**
047: * Returns whether this SInternalFrame be closed.
048: */
049: public boolean isCloseable() {
050: return closeable;
051: }
052:
053: /**
054: * Returns whether this SInternalFrame is currently closed.
055: */
056: public boolean isClosed() {
057: return closed;
058: }
059:
060: /**
061: * Calling this method with a value of <code>true</code> to close
062: * the frame.
063: */
064: public SInternalFrame setClosed(boolean closed) {
065: firePropertyChange("closed", this .closed, this .closed = closed);
066: return this ;
067: }
068:
069: /**
070: * Set that the SInternalFrame can be resized by some user action.
071: */
072: public SInternalFrame setResizable(boolean resizable) {
073: firePropertyChange("resizable", this .resizable,
074: this .resizable = resizable);
075: return this ;
076: }
077:
078: /**
079: * Returns whether the SInternalFrame can be resized by some user action.
080: */
081: public boolean isResizable() {
082: // don't allow resizing when maximized.
083: return maximized ? false : resizable;
084: }
085:
086: /**
087: * Set that the SInternalFrame can be made an icon by some user action.
088: */
089: public SInternalFrame setIconizable(boolean iconizable) {
090: firePropertyChange("iconizable", this .iconizable,
091: this .iconizable = iconizable);
092: return this ;
093: }
094:
095: /**
096: * Returns whether the SInternalFrame can be iconified by some user action.
097: */
098: public boolean isIconizable() {
099: return iconizable;
100: }
101:
102: /**
103: * Returns whether the SInternalFrame is currently iconified.
104: */
105: public boolean isIconized() {
106: return iconized;
107: }
108:
109: /**
110: * Iconizes and deconizes the frame.
111: */
112: public SInternalFrame setIconized(boolean iconized) {
113: firePropertyChange("iconized", this .iconized,
114: this .iconized = iconized);
115: return this ;
116: }
117:
118: /**
119: * Set that the SInternalFrame can be maximized by some user action.
120: */
121: public SInternalFrame setMaximizable(boolean maximizable) {
122: firePropertyChange("maximizable", this .maximizable,
123: this .maximizable = maximizable);
124: return this ;
125: }
126:
127: /**
128: * Returns whether the SInternalFrame can be maximized by some user action.
129: */
130: public boolean isMaximizable() {
131: return maximizable;
132: }
133:
134: /**
135: * Returns whether the SInternalFrame is currently maximized.
136: */
137: public boolean isMaximized() {
138: return maximized;
139: }
140:
141: /**
142: * Maximizes and restores the frame.
143: */
144: public SInternalFrame setMaximized(boolean maximized) {
145: firePropertyChange("maximized", this .maximized,
146: this .maximized = maximized);
147: return this ;
148: }
149:
150: /**
151: * Sets an image to be displayed in the titlebar of the frame (usually
152: * in the top-left corner).
153: * Passing null to this function is valid, but the Theme can choose the
154: * appropriate icon
155: */
156: public SInternalFrame setFrameIcon(SIcon frameIcon) {
157: firePropertyChange("frameIcon", this .frameIcon,
158: this .frameIcon = frameIcon);
159: return this ;
160: }
161:
162: /**
163: * Returns the image displayed in the title bar of the frame (usually
164: * in the top-left corner).
165: */
166: public SIcon getFrameIcon() {
167: return frameIcon;
168: }
169:
170: /**
171: * Set the title of the Page.
172: */
173: public SInternalFrame setTitle(String title) {
174: firePropertyChange("title", this .title, this .title = title);
175: return this ;
176: }
177:
178: /**
179: * Get the title of the Page.
180: */
181: public String getTitle() {
182: return title;
183: }
184:
185: /**
186: * Sets the desktop SIcon associated with this SInternalFrame.
187: */
188: public SInternalFrame setDesktopIcon(SIcon desktopIcon) {
189: firePropertyChange("desktopIcon", this .desktopIcon,
190: this .desktopIcon = desktopIcon);
191: return this ;
192: }
193:
194: /**
195: * Returns the SIcon
196: */
197: public SIcon getDesktopIcon() {
198: return desktopIcon;
199: }
200:
201: /**
202: * Get the collapsed title of the Page.
203: */
204: public String getDesktopTitle() {
205: return desktopTitle;
206: }
207:
208: /**
209: * Set the title of the Page when it is collapsed.
210: */
211: public SInternalFrame setDesktopTitle(String desktopTitle) {
212: firePropertyChange("desktopTitle", this .desktopTitle,
213: this .desktopTitle = desktopTitle);
214: return this ;
215: }
216:
217: // DISPATCH & EVENTS //////////////////////////////////////////////////////
218:
219: /**
220: * Process an AWTEvent
221: */
222: protected void processEvent(AWTEvent event) {
223: if (event instanceof FormEvent) {
224: String buttonType = ((FormEvent) event)
225: .getParameter("_BUTTON");
226: if (STheme.FRAME_MIN.equals(buttonType)) {
227: setIconized(true);
228: } else if (STheme.FRAME_MAX.equals(buttonType)) {
229: setMaximized(true);
230: } else if (STheme.FRAME_RESTORE.equals(buttonType)) {
231: setMaximized(false);
232: } else if (STheme.FRAME_DESKTOP.equals(buttonType)) {
233: setIconized(false);
234: } else if (STheme.FRAME_CLOSE.equals(buttonType)) {
235: setVisible(false);
236: }
237: }
238: }
239:
240: /**
241: * Adds the specified window listener to receive window events from
242: * this window.
243: */
244: public synchronized SInternalFrame addWindowListener(
245: WindowListener listener) {
246: getUI().addListener(listener);
247: return this ;
248: }
249:
250: /**
251: * Removes the specified window listener so that it no longer
252: * receives window events from this window.
253: */
254: public synchronized SInternalFrame removeWindowListener(
255: WindowListener listener) {
256: getUI().removeListener(listener);
257: return this ;
258: }
259:
260: // PRIVATE ///////////////////////////////////////////////////////////////////////////////
261:
262: protected boolean closeable = true;
263: protected boolean closed;
264: protected boolean resizable;
265: protected boolean iconizable = true;
266: protected boolean iconized;
267: protected boolean maximizable = true;
268: protected boolean maximized;
269:
270: protected SIcon frameIcon;
271: protected String title;
272: protected String desktopTitle;
273: protected SIcon desktopIcon;
274:
275: }
|