KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > WindowPane


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app;
31
32 import java.util.EventListener JavaDoc;
33
34 import nextapp.echo2.app.event.WindowPaneEvent;
35 import nextapp.echo2.app.event.WindowPaneListener;
36
37 /**
38  * A <code>Component</code> which renders its contents in a floating,
39  * movable window.
40  * <p>
41  * <b>NOTE:</b> A <code>WindowPane</code> may only be added to
42  * a <code>ContentPane</code>.
43  */

44 public class WindowPane extends Component
45 implements FloatingPane, ModalSupport, PaneContainer {
46
47     public static final String JavaDoc INPUT_CLOSE = "input_close";
48     
49     public static final String JavaDoc PROPERTY_BACKGROUND_IMAGE = "backgroundImage";
50     public static final String JavaDoc PROPERTY_BORDER = "border";
51     public static final String JavaDoc PROPERTY_CLOSABLE = "closable";
52     public static final String JavaDoc PROPERTY_CLOSE_ICON = "closeIcon";
53     public static final String JavaDoc PROPERTY_CLOSE_ICON_INSETS = "closeIconInsets";
54     public static final String JavaDoc PROPERTY_DEFAULT_CLOSE_OPERATION = "defaultCloseOperation";
55     public static final String JavaDoc PROPERTY_HEIGHT = "height";
56     public static final String JavaDoc PROPERTY_ICON = "icon";
57     public static final String JavaDoc PROPERTY_ICON_INSETS = "iconInsets";
58     public static final String JavaDoc PROPERTY_INSETS = "insets";
59     public static final String JavaDoc PROPERTY_MAXIMUM_HEIGHT = "maximumHeight";
60     public static final String JavaDoc PROPERTY_MAXIMUM_WIDTH = "maximumWidth";
61     public static final String JavaDoc PROPERTY_MINIMUM_HEIGHT = "minimumHeight";
62     public static final String JavaDoc PROPERTY_MINIMUM_WIDTH = "minimumWidth";
63     public static final String JavaDoc PROPERTY_MOVABLE = "movable";
64     public static final String JavaDoc PROPERTY_POSITION_X = "positionX";
65     public static final String JavaDoc PROPERTY_POSITION_Y = "positionY";
66     public static final String JavaDoc PROPERTY_RESIZABLE = "resizable";
67     public static final String JavaDoc PROPERTY_TITLE = "title";
68     public static final String JavaDoc PROPERTY_TITLE_BACKGROUND = "titleBackground";
69     public static final String JavaDoc PROPERTY_TITLE_BACKGROUND_IMAGE = "titleBackgroundImage";
70     public static final String JavaDoc PROPERTY_TITLE_BAR_INSETS = "titleBarInsets";
71     public static final String JavaDoc PROPERTY_TITLE_FONT = "titleFont";
72     public static final String JavaDoc PROPERTY_TITLE_FOREGROUND = "titleForeground";
73     public static final String JavaDoc PROPERTY_TITLE_HEIGHT = "titleHeight";
74     public static final String JavaDoc PROPERTY_TITLE_INSETS = "titleInsets";
75     public static final String JavaDoc PROPERTY_WIDTH = "width";
76     
77     public static final String JavaDoc Z_INDEX_CHANGED_PROPERTY = "zIndex";
78
79     /**
80      * A constant for the <code>defaultCloseOperation</code> property
81      * indicating that nothing should be done when the user attempts
82      * to close a window.
83      */

84     public static final int DO_NOTHING_ON_CLOSE = 0;
85
86     /**
87      * A constant for the <code>defaultCloseOperation</code> property
88      * indicating that a window should be hidden when the user attempts
89      * to close it.
90      */

91     public static final int HIDE_ON_CLOSE = 1;
92
93     /**
94      * A constant for the <code>defaultCloseOperation</code> property
95      * indicating that a window should be removed from the component
96      * hierarchy when a user attempts to close it.
97      */

98     public static final int DISPOSE_ON_CLOSE = 2;
99     
100     private boolean modal = false;
101     private int zIndex = 0;
102     
103     /**
104      * Creates a new <code>WindowPane</code>.
105      */

106     public WindowPane() {
107         this(null, null, null);
108     }
109     
110     /**
111      * Creates a new <code>WindowPane</code> with the specified title
112      * and dimensions.
113      *
114      * @param title the title
115      * @param width The width
116      * @param height The height
117      */

118     public WindowPane(String JavaDoc title, Extent width, Extent height) {
119         super();
120         if (title != null) {
121             setTitle(title);
122         }
123         if (width != null) {
124             setWidth(width);
125         }
126         if (height != null) {
127             setHeight(height);
128         }
129     }
130     
131     /**
132      * Adds a <code>WindowPaneListener</code> to receive event notifications.
133      *
134      * @param l the <code>WindowPaneListener</code> to add
135      */

136     public void addWindowPaneListener(WindowPaneListener l) {
137         getEventListenerList().addListener(WindowPaneListener.class, l);
138     }
139     
140     /**
141      * Notifies <code>WindowPaneListener</code>s that the user has requested
142      * to close this <code>WindowPane</code>.
143      */

144     protected void fireWindowClosing() {
145         if (!hasEventListenerList()) {
146             return;
147         }
148         EventListener JavaDoc[] listeners = getEventListenerList().getListeners(WindowPaneListener.class);
149         if (listeners.length == 0) {
150             return;
151         }
152         WindowPaneEvent e = new WindowPaneEvent(this);
153         for (int i = 0; i < listeners.length; ++i) {
154             ((WindowPaneListener) listeners[i]).windowPaneClosing(e);
155         }
156     }
157     
158     /**
159      * Returns the background image of the <code>WindowPane</code>.
160      *
161      * @return the background image
162      */

163     public FillImage getBackgroundImage() {
164         return (FillImage) getProperty(PROPERTY_BACKGROUND_IMAGE);
165     }
166     
167     /**
168      * Returns the border which surrounds the entire <code>WindowPane</code>.
169      *
170      * @return border
171      */

172     public FillImageBorder getBorder() {
173         return (FillImageBorder) getProperty(PROPERTY_BORDER);
174     }
175     
176     /**
177      * Returns the close button icon.
178      *
179      * @return the icon
180      */

181     public ImageReference getCloseIcon() {
182         return (ImageReference) getProperty(PROPERTY_CLOSE_ICON);
183     }
184     
185     /**
186      * Returns the inset margin around the close button icon.
187      *
188      * @return the inset margin
189      */

190     public Insets getCloseIconInsets() {
191         return (Insets) getProperty(PROPERTY_CLOSE_ICON_INSETS);
192     }
193     
194     /**
195      * Returns the default close operation.
196      *
197      * @return the default close operation, one of the following values:
198      * <ul>
199      * <li>DO_NOTHING_ON_CLOSE</li>
200      * <li>HIDE_ON_CLOSE</li>
201      * <li>DISPOSE_ON_CLOSE</li>
202      * </ul>
203      */

204     public int getDefaultCloseOperation() {
205         Integer JavaDoc defaultCloseOperationValue = (Integer JavaDoc) getProperty(PROPERTY_DEFAULT_CLOSE_OPERATION);
206         return defaultCloseOperationValue == null ? 0 : defaultCloseOperationValue.intValue();
207     }
208     
209     /**
210      * Returns the height of the content region of the window.
211      *
212      * @return the height
213      */

214     public Extent getHeight() {
215         return (Extent) getProperty(PROPERTY_HEIGHT);
216     }
217     
218     /**
219      * Returns the icon displayed in the title region.
220      *
221      * @return the icon
222      */

223     public ImageReference getIcon() {
224         return (ImageReference) getProperty(PROPERTY_ICON);
225     }
226     
227     /**
228      * Returns the inset margin around the icon.
229      *
230      * @return the inset margin
231      */

232     public Insets getIconInsets() {
233         return (Insets) getProperty(PROPERTY_CLOSE_ICON_INSETS);
234     }
235     
236     /**
237      * Returns the inset of the window content.
238      * This property is not rendered when the content is a <code>Pane</code>
239      * component.
240      *
241      * @return the inset
242      */

243     public Insets getInsets() {
244         return (Insets) getProperty(PROPERTY_INSETS);
245     }
246     
247     /**
248      * Returns the maximum height of the content region of the
249      * <code>WindowPane</code>.
250      *
251      * @return the maximum height
252      */

253     public Extent getMaximumHeight() {
254         return (Extent) getProperty(PROPERTY_MAXIMUM_HEIGHT);
255     }
256     
257     /**
258      * Returns the maximum width of the content region of the
259      * <code>WindowPane</code>.
260      *
261      * @return the maximum width
262      */

263     public Extent getMaximumWidth() {
264         return (Extent) getProperty(PROPERTY_MAXIMUM_WIDTH);
265     }
266     
267     /**
268      * Returns the minimum height of the content region of the
269      * <code>WindowPane</code>.
270      *
271      * @return the minimum height
272      */

273     public Extent getMinimumHeight() {
274         return (Extent) getProperty(PROPERTY_MINIMUM_HEIGHT);
275     }
276     
277     /**
278      * Returns the minimum width of the content region of the
279      * <code>WindowPane</code>.
280      *
281      * @return the minimum width
282      */

283     public Extent getMinimumWidth() {
284         return (Extent) getProperty(PROPERTY_MINIMUM_WIDTH);
285     }
286     
287     /**
288      * Returns the horizontal (Y) position of the <code>WindowPane</code> with
289      * respect to its container.
290      *
291      * @return the position
292      */

293     public Extent getPositionX() {
294         return (Extent) getProperty(PROPERTY_POSITION_X);
295     }
296     
297     /**
298      * Returns the vertical (Y) position of the <code>WindowPane</code> with
299      * respect to its container.
300      *
301      * @return the position
302      */

303     public Extent getPositionY() {
304         return (Extent) getProperty(PROPERTY_POSITION_Y);
305     }
306     
307     /**
308      * Returns the title of the <code>WindowPane</code>.
309      *
310      * @return the title
311      */

312     public String JavaDoc getTitle() {
313         return (String JavaDoc) getProperty(PROPERTY_TITLE);
314     }
315     
316     /**
317      * Returns the background color of the title region.
318      *
319      * @return the color
320      */

321     public Color getTitleBackground() {
322         return (Color) getProperty(PROPERTY_TITLE_BACKGROUND);
323     }
324     
325     /**
326      * Returns the background image of the title region.
327      *
328      * @return the background image
329      */

330     public FillImage getTitleBackgroundImage() {
331         return (FillImage) getProperty(PROPERTY_TITLE_BACKGROUND_IMAGE);
332     }
333
334     /**
335      * Returns the horizontal inset of the entire title bar (relative to the content area).
336      * Setting this value will result in the title bar being narrower than the rest of the
337      * content region, which may be necessary to accommodate particular border styles.
338      *
339      * @return the insets
340      */

341     public Insets getTitleBarInsets() {
342         return (Insets) getProperty(PROPERTY_TITLE_BAR_INSETS);
343     }
344     
345     /**
346      * Returns the font of the title region.
347      *
348      * @return the font
349      */

350     public Font getTitleFont() {
351         return (Font) getProperty(PROPERTY_TITLE_FONT);
352     }
353     
354     /**
355      * Returns the foreground color of the title region.
356      *
357      * @return the color
358      */

359     public Color getTitleForeground() {
360         return (Color) getProperty(PROPERTY_TITLE_FOREGROUND);
361     }
362     
363     /**
364      * Returns the height of the title region.
365      *
366      * @return the height
367      */

368     public Extent getTitleHeight() {
369         return (Extent) getProperty(PROPERTY_TITLE_HEIGHT);
370     }
371
372     /**
373      * Returns the insets of the title region.
374      *
375      * @return the insets
376      */

377     public Insets getTitleInsets() {
378         return (Insets) getProperty(PROPERTY_TITLE_INSETS);
379     }
380
381     /**
382      * Returns the width of the content region of the window.
383      *
384      * @return the width
385      */

386     public Extent getWidth() {
387         return (Extent) getProperty(PROPERTY_WIDTH);
388     }
389     
390     /**
391      * Returns the z-index of the window with respect to its parent
392      * <code>ContentPane</code>. Windows with higher z-indices will
393      * visually obscure windows with lower z-indices.
394      *
395      * @return the z-index
396      */

397     public int getZIndex() {
398         return zIndex;
399     }
400     
401     /**
402      * Determines if the window is closable via a provided close button in
403      * the title bar.
404      *
405      * @return true if the window is closable
406      */

407     public boolean isClosable() {
408         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_CLOSABLE);
409         return value == null ? true: value.booleanValue();
410     }
411     
412     /**
413      * @see nextapp.echo2.app.ModalSupport#isModal()
414      */

415     public boolean isModal() {
416         return modal;
417     }
418     
419     /**
420      * Determines if the window is movable.
421      *
422      * @return true if the window is movable
423      */

424     public boolean isMovable() {
425         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_MOVABLE);
426         return value == null ? true : value.booleanValue();
427     }
428
429     /**
430      * Determines if the window is resizable.
431      *
432      * @return true if the window is resizable
433      */

434     public boolean isResizable() {
435         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_RESIZABLE);
436         return value == null ? true : value.booleanValue();
437     }
438     
439     /**
440      * Limit content to a single child.
441      *
442      * @see nextapp.echo2.app.Component#isValidChild(nextapp.echo2.app.Component)
443      */

444     public boolean isValidChild(Component component) {
445         return getComponentCount() == 0;
446     }
447     
448     /**
449      * Only allow <code>ContentPane</code>s as parents.
450      *
451      * @see nextapp.echo2.app.Component#isValidParent(nextapp.echo2.app.Component)
452      */

453     public boolean isValidParent(Component parent) {
454         return parent instanceof ContentPane;
455     }
456     
457     /**
458      * @see nextapp.echo2.app.Component#processInput(java.lang.String, java.lang.Object)
459      */

460     public void processInput(String JavaDoc inputName, Object JavaDoc inputValue) {
461         if (INPUT_CLOSE.equals(inputName)) {
462             userClose();
463         } else if (PROPERTY_POSITION_X.equals(inputName)) {
464             setPositionX((Extent) inputValue);
465         } else if (PROPERTY_POSITION_Y.equals(inputName)) {
466             setPositionY((Extent) inputValue);
467         } else if (PROPERTY_WIDTH.equals(inputName)) {
468             setWidth((Extent) inputValue);
469         } else if (PROPERTY_HEIGHT.equals(inputName)) {
470             setHeight((Extent) inputValue);
471         } else if (Z_INDEX_CHANGED_PROPERTY.equals(inputName)) {
472             setZIndex(((Integer JavaDoc) inputValue).intValue());
473         }
474     }
475     
476     /**
477      * Sets the background image of the <code>WindowPane</code>.
478      *
479      * @param newValue the new background image
480      */

481     public void setBackgroundImage(FillImage newValue) {
482         setProperty(PROPERTY_BACKGROUND_IMAGE, newValue);
483     }
484     
485     /**
486      * Sets the border which surrounds the entire <code>WindowPane</code>.
487      *
488      * @param newValue the new border
489      */

490     public void setBorder(FillImageBorder newValue) {
491         setProperty(PROPERTY_BORDER, newValue);
492     }
493     
494     /**
495      * Sets whether the window is closable via a provided close button in
496      * the title bar.
497      *
498      * @param newValue true if the window is closable
499      */

500     public void setClosable(boolean newValue) {
501         setProperty(PROPERTY_CLOSABLE, new Boolean JavaDoc(newValue));
502     }
503     
504     /**
505      * Sets the close button icon.
506      *
507      * @param newValue the new icon
508      */

509     public void setCloseIcon(ImageReference newValue) {
510         setProperty(PROPERTY_CLOSE_ICON, newValue);
511     }
512     
513     /**
514      * Sets the inset margin around the close button icon.
515      *
516      * @param newValue the new inset margin
517      */

518     public void setCloseIconInsets(Insets newValue) {
519         setProperty(PROPERTY_CLOSE_ICON_INSETS, newValue);
520     }
521     
522     /**
523      * Sets the default close operation.
524      *
525      * @param newValue the new default close operation, one of the following
526      * values:
527      * <ul>
528      * <li>DO_NOTHING_ON_CLOSE</li>
529      * <li>HIDE_ON_CLOSE</li>
530      * <li>DISPOSE_ON_CLOSE</li>
531      * </ul>
532      */

533     public void setDefaultCloseOperation(int newValue) {
534         setProperty(PROPERTY_DEFAULT_CLOSE_OPERATION, new Integer JavaDoc(newValue));
535     }
536     
537     /**
538      * Sets the height of the content region of the <code>WindowPane</code>.
539      * Values must be in pixel units.
540      *
541      * @param newValue the new height
542      */

543     public void setHeight(Extent newValue) {
544         Extent.validate(newValue, Extent.PX);
545         setProperty(PROPERTY_HEIGHT, newValue);
546     }
547     
548     /**
549      * Sets the icon displayed in the title region.
550      *
551      * @param newValue the new icon
552      */

553     public void setIcon(ImageReference newValue) {
554         setProperty(PROPERTY_ICON, newValue);
555     }
556     
557     /**
558      * Sets the inset margin around the icon.
559      *
560      * @param newValue the new inset margin
561      */

562     public void setIconInsets(Insets newValue) {
563         setProperty(PROPERTY_ICON_INSETS, newValue);
564     }
565     
566     /**
567      * Sets the inset of the window content.
568      * This property is not rendered when the content is a <code>Pane</code>
569      * component.
570      *
571      * @param newValue the new inset
572      */

573     public void setInsets(Insets newValue) {
574         setProperty(PROPERTY_INSETS, newValue);
575     }
576     
577     /**
578      * Sets the maximum height of the content region of the
579      * <code>WindowPane</code>.
580      * Values must be in pixel units.
581      *
582      * @param newValue the new maximum height
583      */

584     public void setMaximumHeight(Extent newValue) {
585         Extent.validate(newValue, Extent.PX);
586         setProperty(PROPERTY_MAXIMUM_HEIGHT, newValue);
587     }
588     
589     /**
590      * Sets the maximum width of the content region of the
591      * <code>WindowPane</code>.
592      * Values must be in pixel units.
593      *
594      * @param newValue the new maximum width
595      */

596     public void setMaximumWidth(Extent newValue) {
597         Extent.validate(newValue, Extent.PX);
598         setProperty(PROPERTY_MAXIMUM_WIDTH, newValue);
599     }
600     
601     /**
602      * Sets the minimum height of the content region of the
603      * <code>WindowPane</code>.
604      * Values must be in pixel units.
605      *
606      * @param newValue the new minimum height
607      */

608     public void setMinimumHeight(Extent newValue) {
609         Extent.validate(newValue, Extent.PX);
610         setProperty(PROPERTY_MINIMUM_HEIGHT, newValue);
611     }
612     
613     /**
614      * Sets the minimum width of the content region of the
615      * <code>WindowPane</code>.
616      * Values must be in pixel units.
617      *
618      * @param newValue the new minimum width
619      */

620     public void setMinimumWidth(Extent newValue) {
621         Extent.validate(newValue, Extent.PX);
622         setProperty(PROPERTY_MINIMUM_WIDTH, newValue);
623     }
624     
625     /**
626      * @see nextapp.echo2.app.ModalSupport#setModal(boolean)
627      */

628     public void setModal(boolean newValue) {
629         boolean oldValue = modal;
630         modal = newValue;
631         firePropertyChange(MODAL_CHANGED_PROPERTY, new Boolean JavaDoc(oldValue), new Boolean JavaDoc(newValue));
632     }
633     
634     /**
635      * Sets whether the window is movable.
636      *
637      * @param newValue true if the window may be moved by the user
638      */

639     public void setMovable(boolean newValue) {
640         setProperty(PROPERTY_MOVABLE, new Boolean JavaDoc(newValue));
641     }
642     
643     /**
644      * Sets the horizontal (X) position of the <code>WindowPane</code> with
645      * respect to its container.
646      * Values must be in pixel units.
647      *
648      * @param newValue the new position
649      */

650     public void setPositionX(Extent newValue) {
651         Extent.validate(newValue, Extent.PX);
652         setProperty(PROPERTY_POSITION_X, newValue);
653     }
654     
655     /**
656      * Sets the vertical (Y) position of the <code>WindowPane</code> with
657      * respect to its container.
658      * Values must be in pixel units.
659      *
660      * @param newValue the new position
661      */

662     public void setPositionY(Extent newValue) {
663         Extent.validate(newValue, Extent.PX);
664         setProperty(PROPERTY_POSITION_Y, newValue);
665     }
666
667     /**
668      * Sets whether the window is resizable.
669      *
670      * @param newValue true if the window may be resized by the user
671      */

672     public void setResizable(boolean newValue) {
673         setProperty(PROPERTY_RESIZABLE, new Boolean JavaDoc(newValue));
674     }
675     
676     /**
677      * Sets the title of the <code>WindowPane</code>.
678      *
679      * @param newValue the title
680      */

681     public void setTitle(String JavaDoc newValue) {
682         setProperty(PROPERTY_TITLE, newValue);
683     }
684     
685     /**
686      * Sets the background color of the title region.
687      *
688      * @param newValue the new color
689      */

690     public void setTitleBackground(Color newValue) {
691         setProperty(PROPERTY_TITLE_BACKGROUND, newValue);
692     }
693     
694     /**
695      * Sets the background image of the title region.
696      *
697      * @param newValue the new background image
698      */

699     public void setTitleBackgroundImage(FillImage newValue) {
700         setProperty(PROPERTY_TITLE_BACKGROUND_IMAGE, newValue);
701     }
702     
703     /**
704      * Sets the horizontal inset of the entire title bar (relative to the content area).
705      * Setting this value will result in the title bar being narrower than the rest of the
706      * content region, which may be necessary to accommodate particular border styles.
707      *
708      * @param newValue the new insets
709      */

710     public void setTitleBarInsets(Insets newValue) {
711         setProperty(PROPERTY_TITLE_BAR_INSETS, newValue);
712     }
713     
714     /**
715      * Sets the font of the title region.
716      *
717      * @param newValue the new font
718      */

719     public void setTitleFont(Font newValue) {
720         setProperty(PROPERTY_TITLE_FONT, newValue);
721     }
722     
723     /**
724      * Sets the foreground color of the title region.
725      *
726      * @param newValue the new color
727      */

728     public void setTitleForeground(Color newValue) {
729         setProperty(PROPERTY_TITLE_FOREGROUND, newValue);
730     }
731     
732     /**
733      * Sets the height of the title region.
734      * Values must be in pixel units.
735      *
736      * @param newValue the new height
737      */

738     public void setTitleHeight(Extent newValue) {
739         Extent.validate(newValue, Extent.PX);
740         setProperty(PROPERTY_TITLE_HEIGHT, newValue);
741     }
742     
743     /**
744      * Sets the insets of the title region.
745      *
746      * @param newValue the new insets
747      */

748     public void setTitleInsets(Insets newValue) {
749         setProperty(PROPERTY_TITLE_INSETS, newValue);
750     }
751     
752     /**
753      * Sets the width of the content region of the window.
754      * Values must be in pixel units.
755      *
756      * @param newValue the new width
757      */

758     public void setWidth(Extent newValue) {
759         Extent.validate(newValue, Extent.PX);
760         setProperty(PROPERTY_WIDTH, newValue);
761     }
762     
763     /**
764      * Sets the z-index of the window with respect to its parent
765      * <code>ContentPane</code>. Windows with higher z-indices will
766      * visually obscure windows with lower z-indices.
767      *
768      * @param newValue the new z-index
769      */

770     public void setZIndex(int newValue) {
771         int oldValue = zIndex;
772         zIndex = newValue;
773         firePropertyChange(Z_INDEX_CHANGED_PROPERTY, new Integer JavaDoc(oldValue), new Integer JavaDoc(newValue));
774     }
775     
776     /**
777      * Removes a <code>WindowPaneListener</code> from receiving event notifications.
778      *
779      * @param l the <code>WindowPaneListener</code> to remove
780      */

781     public void removeWindowPaneListener(WindowPaneListener l) {
782         if (!hasEventListenerList()) {
783             return;
784         }
785         getEventListenerList().removeListener(WindowPaneListener.class, l);
786     }
787     
788     /**
789      * Processes a user request to close the window (via the close button).
790      */

791     public void userClose() {
792         fireWindowClosing();
793         Integer JavaDoc defaultCloseOperationValue = (Integer JavaDoc) getRenderProperty(PROPERTY_DEFAULT_CLOSE_OPERATION);
794         int defaultCloseOperation = defaultCloseOperationValue == null
795                 ? DISPOSE_ON_CLOSE : defaultCloseOperationValue.intValue();
796         switch (defaultCloseOperation) {
797         case DISPOSE_ON_CLOSE:
798             getParent().remove(this);
799             break;
800         case HIDE_ON_CLOSE:
801             setVisible(false);
802             break;
803         }
804     }
805 }
806
Popular Tags