KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > testapp > interactive > testscreen > WindowPaneExamplesTest


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.testapp.interactive.testscreen;
31
32 import nextapp.echo2.app.Alignment;
33 import nextapp.echo2.app.Border;
34 import nextapp.echo2.app.Button;
35 import nextapp.echo2.app.CheckBox;
36 import nextapp.echo2.app.Color;
37 import nextapp.echo2.app.ContentPane;
38 import nextapp.echo2.app.Extent;
39 import nextapp.echo2.app.Grid;
40 import nextapp.echo2.app.Insets;
41 import nextapp.echo2.app.Label;
42 import nextapp.echo2.app.Column;
43 import nextapp.echo2.app.ListBox;
44 import nextapp.echo2.app.RadioButton;
45 import nextapp.echo2.app.SelectField;
46 import nextapp.echo2.app.SplitPane;
47 import nextapp.echo2.app.Table;
48 import nextapp.echo2.app.TextArea;
49 import nextapp.echo2.app.TextField;
50 import nextapp.echo2.app.WindowPane;
51 import nextapp.echo2.app.button.ButtonGroup;
52 import nextapp.echo2.app.event.ActionEvent;
53 import nextapp.echo2.app.event.ActionListener;
54 import nextapp.echo2.app.layout.SplitPaneLayoutData;
55 import nextapp.echo2.testapp.interactive.ButtonColumn;
56 import nextapp.echo2.testapp.interactive.InteractiveApp;
57 import nextapp.echo2.testapp.interactive.StyleUtil;
58 import nextapp.echo2.testapp.interactive.Styles;
59
60 /**
61  * Interactive test for <code>WindowPane</code>s.
62  */

63 public class WindowPaneExamplesTest extends SplitPane {
64     
65     private class WindowTestControls extends ButtonColumn {
66         
67         private WindowTestControls(String JavaDoc targetName, final ContentPane targetContentPane) {
68             add(new Label(targetName));
69             addButton("Add Test Window", new ActionListener() {
70                 public void actionPerformed(ActionEvent e) {
71                     targetContentPane.add(createTestWindow("Test"));
72                 }
73             });
74             addButton("Add Label Window", new ActionListener() {
75                 public void actionPerformed(ActionEvent e) {
76                     targetContentPane.add(createSimpleWindow("Simple"));
77                 }
78             });
79             addButton("Add GlassBlue Window", new ActionListener() {
80                 public void actionPerformed(ActionEvent e) {
81                     WindowPane windowPane = createSimpleWindow("GlassBlue");
82                     windowPane.setStyleName("GlassBlue");
83                     targetContentPane.add(windowPane);
84                 }
85             });
86             addButton("Add TransGreen Window", new ActionListener() {
87                 public void actionPerformed(ActionEvent e) {
88                     WindowPane windowPane = createSimpleWindow("TransGreen");
89                     windowPane.setStyleName("TransGreen");
90                     targetContentPane.add(windowPane);
91                 }
92             });
93             addButton("Add Modal Window", new ActionListener() {
94                 public void actionPerformed(ActionEvent e) {
95                     WindowPane windowPane = createModalWindow("Modal");
96                     windowPane.setModal(true);
97                     targetContentPane.add(windowPane);
98                 }
99             });
100             addButton("Add Three Modal Windows", new ActionListener() {
101                 public void actionPerformed(ActionEvent e) {
102                     for (int i = 0; i < 3; ++i) {
103                         WindowPane windowPane = createModalWindow("3Modal");
104                         windowPane.setModal(true);
105                         targetContentPane.add(windowPane);
106                     }
107                 }
108             });
109             addButton("Add Modal Window In A Window", new ActionListener() {
110                 public void actionPerformed(ActionEvent e) {
111                     WindowPane w1 = new WindowPane();
112                     w1.setStyleName("Default");
113                     w1.setWidth(new Extent(650));
114                     w1.setHeight(new Extent(450));
115                     w1.setTitle("Just A Window");
116                     targetContentPane.add(w1);
117                     
118                     ContentPane c1 = new ContentPane();
119                     final Button b1 = new Button("Click me:");
120                     b1.setStyleName("Default");
121                     b1.addActionListener(new ActionListener() {
122                         public void actionPerformed(ActionEvent e) {
123                             b1.setText(b1.getText() + "!");
124                         }
125                     });
126                     c1.add(b1);
127
128                     w1.add(c1);
129                     
130                     WindowPane w2 = new WindowPane();
131                     w2.setStyleName("Default");
132                     final Button b2 = new Button("Click me:");
133                     b2.setStyleName("Default");
134                     b2.addActionListener(new ActionListener() {
135                         public void actionPerformed(ActionEvent e) {
136                             b2.setText(b2.getText() + "!");
137                         }
138                     });
139                     w2.add(b2);
140                     
141                     w2.setTitle("But this one is modal.");
142                     w2.setModal(true);
143                     
144                     c1.add(w2);
145                 }
146             });
147             addButton("Add Constrained Size Window", new ActionListener() {
148                 public void actionPerformed(ActionEvent e) {
149                     WindowPane windowPane = createSimpleWindow("Constrained");
150                     windowPane.setMinimumWidth(new Extent(400));
151                     windowPane.setMaximumWidth(new Extent(500));
152                     windowPane.setMinimumHeight(new Extent(200));
153                     windowPane.setMaximumHeight(new Extent(280));
154                     targetContentPane.add(windowPane);
155                 }
156             });
157             addButton("Add Default-Border Window", new ActionListener() {
158                 public void actionPerformed(ActionEvent e) {
159                     final WindowPane windowPane = new WindowPane();
160                     positionWindowPane(windowPane);
161                     windowPane.setTitle("Default-Border Window #" + windowNumber++);
162                     targetContentPane.add(windowPane);
163                     
164                     Column windowPaneColumn = new Column();
165                     windowPane.add(windowPaneColumn);
166                     windowPaneColumn.add(new Label("First Name:"));
167                     windowPaneColumn.add(new TextField());
168                     windowPaneColumn.add(new Label("Last Name:"));
169                     windowPaneColumn.add(new TextField());
170                 }
171             });
172             addButton("Add Immovable Window", new ActionListener() {
173                 public void actionPerformed(ActionEvent e) {
174                     WindowPane windowPane = createSimpleWindow("Immovable");
175                     windowPane.setMovable(false);
176                     targetContentPane.add(windowPane);
177                 }
178             });
179             addButton("Add Fixed Size Window", new ActionListener() {
180                 public void actionPerformed(ActionEvent e) {
181                     WindowPane windowPane = createSimpleWindow("Fixed Size");
182                     windowPane.setResizable(false);
183                     targetContentPane.add(windowPane);
184                 }
185             });
186             addButton("Add Immovable Fixed Size Window", new ActionListener() {
187                 public void actionPerformed(ActionEvent e) {
188                     WindowPane windowPane = createSimpleWindow("Immovable Fixed Size");
189                     windowPane.setMovable(false);
190                     windowPane.setResizable(false);
191                     targetContentPane.add(windowPane);
192                 }
193             });
194             addButton("Add SplitPane Window (No Close Icon)", new ActionListener() {
195                 public void actionPerformed(ActionEvent e) {
196                     final WindowPane windowPane = new WindowPane();
197                     windowPane.setClosable(false);
198                     positionWindowPane(windowPane);
199                     targetContentPane.add(windowPane);
200                     windowPane.setTitle("SplitPane Window #" + windowNumber++);
201                     windowPane.setTitleInsets(new Insets(10, 5));
202                     windowPane.setStyleName("Default");
203                     windowPane.setTitleBackground(new Color(0x2f2f4f));
204                     windowPane.setWidth(new Extent(500, Extent.PX));
205                     windowPane.setHeight(new Extent(300, Extent.PX));
206                     SplitPane splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new Extent(42));
207                     SplitPaneLayoutData splitPaneLayoutData;
208                     
209                     Button okButton = new Button("Ok");
210                     okButton.addActionListener(new ActionListener() {
211                         /**
212                          * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
213                          */

214                         public void actionPerformed(ActionEvent e) {
215                             windowPane.getParent().remove(windowPane);
216                         }
217                     });
218                     splitPaneLayoutData = new SplitPaneLayoutData();
219                     splitPaneLayoutData.setBackground(new Color(0x5f5f9f));
220                     splitPaneLayoutData.setInsets(new Insets(8));
221                     splitPaneLayoutData.setAlignment(new Alignment(Alignment.CENTER, Alignment.DEFAULT));
222                     splitPaneLayoutData.setOverflow(SplitPaneLayoutData.OVERFLOW_HIDDEN);
223                     okButton.setLayoutData(splitPaneLayoutData);
224                     okButton.setWidth(new Extent(100));
225                     okButton.setStyleName("Default");
226                     splitPane.add(okButton);
227                     
228                     Label contentLabel = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
229                     splitPaneLayoutData = new SplitPaneLayoutData();
230                     splitPaneLayoutData.setBackground(new Color(0xefefff));
231                     contentLabel.setLayoutData(splitPaneLayoutData);
232                     splitPane.add(contentLabel);
233                     
234                     windowPane.add(splitPane);
235                 }
236             });
237     
238             addButton("Add Multiple SplitPane Nautilus Window", new ActionListener() {
239                 public void actionPerformed(ActionEvent e) {
240                     final WindowPane windowPane = new WindowPane();
241                     windowPane.setStyleName("Default");
242                     windowPane.setWidth(new Extent(500, Extent.PX));
243                     windowPane.setHeight(new Extent(500, Extent.PX));
244                     windowPane.setTitle("SP Nautilus Window #" + windowNumber++);
245                     windowPane.add(new SplitPaneNestedTest(new Extent(50)));
246                     positionWindowPane(windowPane);
247                     targetContentPane.add(windowPane);
248                 }
249             });
250             
251             addButton("Add Multiple SplitPane Window", new ActionListener() {
252                 public void actionPerformed(ActionEvent e) {
253                     final WindowPane windowPane = new WindowPane();
254                     positionWindowPane(windowPane);
255                     targetContentPane.add(windowPane);
256                     windowPane.setTitle("Multiple SplitPane Window #" + windowNumber++);
257                     windowPane.setTitleInsets(new Insets(10, 5));
258                     windowPane.setStyleName("Default");
259                     windowPane.setTitleBackground(new Color(0x2f2f4f));
260                     windowPane.setWidth(new Extent(700, Extent.PX));
261                     windowPane.setHeight(new Extent(500, Extent.PX));
262                     
263                     SplitPane splitPane1 = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL, new Extent(100));
264                     splitPane1.setStyleName("DefaultResizable");
265                     SplitPaneLayoutData splitPaneLayoutData;
266                     
267                     Label label;
268                     
269                     label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
270                     splitPaneLayoutData = new SplitPaneLayoutData();
271                     splitPaneLayoutData.setBackground(new Color(0x3fbf5f));
272                     splitPaneLayoutData.setInsets(new Insets(5));
273                     label.setLayoutData(splitPaneLayoutData);
274                     splitPane1.add(label);
275
276                     SplitPane splitPane2 = new SplitPane(SplitPane.ORIENTATION_VERTICAL, new Extent(120));
277                     splitPane2.setStyleName("DefaultResizable");
278                     
279                     SplitPane splitPane3 = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL, new Extent(200));
280                     splitPane3.setStyleName("DefaultResizable");
281                     splitPane2.add(splitPane3);
282                     
283                     SplitPane splitPane4 = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL, new Extent(300));
284                     splitPane4.setStyleName("DefaultResizable");
285                     splitPane2.add(splitPane4);
286                     
287                     label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
288                     splitPaneLayoutData = new SplitPaneLayoutData();
289                     splitPaneLayoutData.setBackground(new Color(0x5f3fbf));
290                     splitPaneLayoutData.setInsets(new Insets(5));
291                     label.setLayoutData(splitPaneLayoutData);
292                     splitPane3.add(label);
293                     
294                     label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
295                     splitPaneLayoutData = new SplitPaneLayoutData();
296                     splitPaneLayoutData.setBackground(new Color(0x3f5fbf));
297                     splitPaneLayoutData.setInsets(new Insets(5));
298                     label.setLayoutData(splitPaneLayoutData);
299                     splitPane3.add(label);
300                     
301                     label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
302                     splitPaneLayoutData = new SplitPaneLayoutData();
303                     splitPaneLayoutData.setBackground(new Color(0xbf5f3f));
304                     splitPaneLayoutData.setInsets(new Insets(5));
305                     label.setLayoutData(splitPaneLayoutData);
306                     splitPane4.add(label);
307                     
308                     label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
309                     splitPaneLayoutData = new SplitPaneLayoutData();
310                     splitPaneLayoutData.setBackground(new Color(0xbf3f5f));
311                     splitPaneLayoutData.setInsets(new Insets(5));
312                     label.setLayoutData(splitPaneLayoutData);
313                     splitPane4.add(label);
314     
315                     splitPane1.add(splitPane2);
316                     
317                     windowPane.add(splitPane1);
318                 }
319             });
320
321             addButton("Add Mozilla TextField Quirk Workaround Test Window", new ActionListener() {
322                 public void actionPerformed(ActionEvent e) {
323                     targetContentPane.add(createMozillaTextFieldQuirkTestWindow());
324                 }
325             });
326             
327             addButton("Add init() bug-fix test Window", new ActionListener() {
328                 public void actionPerformed(ActionEvent e) {
329                     WindowPane windowPane = new WindowPane();
330                     windowPane.add(new Column() {
331                         public void init() {
332                             super.init();
333                             add(new Label("Test"));
334                         }
335                         public void dispose() {
336                             removeAll();
337                             super.dispose();
338                         }
339                     });
340                     targetContentPane.add(windowPane);
341                 }
342             });
343         }
344     }
345
346     /**
347      * Counter used to position new <code>WindowPane</code>s on the screen.
348      */

349     private int nextPosition = 0;
350     
351     /**
352      * Counter used to assign somewhat unique titles.
353      */

354     private int windowNumber = 0;
355
356     public WindowPaneExamplesTest() {
357         super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX));
358         setStyleName("DefaultResizable");
359         
360         ButtonColumn controlsColumn = new ButtonColumn();
361         controlsColumn.setCellSpacing(new Extent(5));
362         controlsColumn.setStyleName("TestControlsColumn");
363         add(controlsColumn);
364         
365         ContentPane contentPane = new ContentPane();
366         add(contentPane);
367         
368         final Column contentColumn = new Column();
369         contentPane.add(contentColumn);
370         
371         WindowTestControls windowTestControls;
372         windowTestControls = new WindowTestControls("Root Level", InteractiveApp.getApp().getDefaultWindow().getContent());
373         controlsColumn.add(windowTestControls);
374         windowTestControls = new WindowTestControls("Embedded", contentPane);
375         controlsColumn.add(windowTestControls);
376         
377         Column componentSamplerControlsColumn = new Column();
378         componentSamplerControlsColumn.add(new Label("Component \"Sampler\""));
379         controlsColumn.add(componentSamplerControlsColumn);
380
381         Button button;
382
383         button = new Button("Add Component Sampler to Embedded ContentPane");
384         button.setStyleName("Default");
385         button.addActionListener(new ActionListener() {
386             public void actionPerformed(ActionEvent e) {
387                 addComponentSampler(contentColumn, false);
388             }
389         });
390         componentSamplerControlsColumn.add(button);
391
392         button = new Button("Add \"Modal Launching\" Component Sampler to Embedded ContentPane");
393         button.setStyleName("Default");
394         button.addActionListener(new ActionListener() {
395             public void actionPerformed(ActionEvent e) {
396                 addComponentSampler(contentColumn, true);
397             }
398         });
399         componentSamplerControlsColumn.add(button);
400
401         button = new Button("Clear Embedded ContentPane");
402         button.setStyleName("Default");
403         button.addActionListener(new ActionListener() {
404             public void actionPerformed(ActionEvent e) {
405                 contentColumn.removeAll();
406             }
407         });
408         componentSamplerControlsColumn.add(button);
409     }
410     
411     private void addComponentSampler(Column contentColumn, boolean launchModals) {
412         Column componentSamplerColumn = new Column();
413         if (launchModals) {
414             componentSamplerColumn.setBorder(new Border(new Extent(5, Extent.PX), new Color(0xffafaf), Border.STYLE_INSET));
415         } else {
416             componentSamplerColumn.setBorder(new Border(new Extent(5, Extent.PX), new Color(0xafafff), Border.STYLE_INSET));
417         }
418         componentSamplerColumn.setInsets(new Insets(10));
419         componentSamplerColumn.setCellSpacing(new Extent(1));
420         contentColumn.add(componentSamplerColumn);
421         
422         for (int i = 1; i <= 3; ++i) {
423             Button button = new Button("Button #" + i);
424             button.setStyleName("Default");
425             componentSamplerColumn.add(button);
426             if (launchModals && i == 1) {
427                 button.addActionListener(new ActionListener() {
428                     public void actionPerformed(ActionEvent e) {
429                         getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
430                     }
431                 });
432             }
433         }
434         
435         ButtonGroup buttonGroup = new ButtonGroup();
436         for (int i = 1; i <= 3; ++i) {
437             RadioButton radioButton = new RadioButton("RadioButton #" + i);
438             radioButton.setGroup(buttonGroup);
439             radioButton.setStyleName("Default");
440             componentSamplerColumn.add(radioButton);
441             if (launchModals && i == 1) {
442                 radioButton.addActionListener(new ActionListener() {
443                     public void actionPerformed(ActionEvent e) {
444                         getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
445                     }
446                 });
447             }
448         }
449         
450         for (int i = 1; i <= 3; ++i) {
451             CheckBox checkBox = new CheckBox("CheckBox #" + i);
452             checkBox.setStyleName("Default");
453             componentSamplerColumn.add(checkBox);
454             if (launchModals && i == 1) {
455                 checkBox.addActionListener(new ActionListener() {
456                     public void actionPerformed(ActionEvent e) {
457                         getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
458                     }
459                 });
460             }
461         }
462         
463         Table table = new Table(TableTest.createEmployeeTableModel());
464         table.setBorder(new Border(new Extent(2), new Color(0xafffcf), Border.STYLE_GROOVE));
465         table.setInsets(new Insets(15, 5));
466         table.setSelectionEnabled(true);
467         table.setSelectionBackground(new Color(0xffcfaf));
468         table.setRolloverEnabled(true);
469         table.setRolloverBackground(new Color(0xafefff));
470         if (launchModals) {
471             table.addActionListener(new ActionListener() {
472                 public void actionPerformed(ActionEvent e) {
473                     getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
474                 }
475             });
476         }
477         componentSamplerColumn.add(table);
478         
479         ListBox listBox = new ListBox(ListBoxTest.NUMBERS);
480         if (launchModals) {
481             listBox.addActionListener(new ActionListener() {
482                 public void actionPerformed(ActionEvent e) {
483                     getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
484                 }
485             });
486         }
487         componentSamplerColumn.add(listBox);
488
489         SelectField selectField = new SelectField(ListBoxTest.NUMBERS);
490         if (launchModals) {
491             selectField.addActionListener(new ActionListener() {
492                 public void actionPerformed(ActionEvent e) {
493                     getApplicationInstance().getDefaultWindow().getContent().add(createComponentSamplerModalTestWindow());
494                 }
495             });
496         }
497         componentSamplerColumn.add(selectField);
498     }
499     
500     private WindowPane createComponentSamplerModalTestWindow() {
501         WindowPane windowPane = createSimpleWindow("Component Sampler Modal Test Window");
502         windowPane.setModal(true);
503         return windowPane;
504     }
505     
506     private WindowPane createModalWindow(String JavaDoc name) {
507         final WindowPane windowPane = new WindowPane();
508         positionWindowPane(windowPane);
509         windowPane.setTitle(name + " Window #" + windowNumber++);
510         windowPane.setTitleInsets(new Insets(10, 5));
511         windowPane.setTitleBackground(new Color(0x2f2f4f));
512         windowPane.setInsets(new Insets(10));
513         windowPane.setWidth(new Extent(500));
514         windowPane.setHeight(new Extent(280));
515         windowPane.setStyleName("Default");
516         
517         ButtonColumn column = new ButtonColumn();
518         windowPane.add(column);
519
520         column.addButton("Add Modal Window", new ActionListener() {
521             public void actionPerformed(ActionEvent e) {
522                 ContentPane contentPane = (ContentPane) windowPane.getParent();
523                 WindowPane newWindowPane = createModalWindow("YetAnotherModal");
524                 newWindowPane.setModal(true);
525                 contentPane.add(newWindowPane);
526             }
527         });
528         
529         return windowPane;
530     }
531
532     private WindowPane createMozillaTextFieldQuirkTestWindow() {
533        final WindowPane windowPane = new WindowPane();
534        //positionWindowPane(windowPane);
535
windowPane.setTitle("****Bug F1047 Window #" + windowNumber++);
536        windowPane.setStyleName("Default");
537
538        final Column mainColumn = new Column();
539        
540        Grid grid = new Grid();
541        mainColumn.add(grid);
542        
543        grid.add(new Label("User"));
544        TextField tf = new TextField();
545        tf.setText("This Text will render somewhere");
546        grid.add(tf);
547        grid.add(new Label("Subject"));
548        tf = new TextField();
549        tf.setText("BLANK OUT THIS FIELD!!!");
550        grid.add(tf);
551        grid.add(new Label("Message"));
552        grid.add(new TextArea());
553        grid.add(new Label("Stuff"));
554        grid.add(new ListBox(new Object JavaDoc[]{"one", "two", "three"}));
555        grid.add(new Label("Things"));
556        grid.add(new SelectField(new Object JavaDoc[]{"four", "five", "six"}));
557        
558        Button okButton = new Button("Ok");
559        okButton.addActionListener(new ActionListener() {
560            public void actionPerformed(ActionEvent e) {
561                Column errorColumn = new Column();
562                errorColumn.add(new Label("Did Mozilla break?"));
563                errorColumn.add(new Label("Did Mozilla break?"));
564                mainColumn.add(errorColumn, 0);
565                //**** UNCOMMENT THE FOLLWOING LINE FOR "FIXING" THIS BUG
566
//windowPane.setHeight(windowPane.getHeight());
567
}
568        });
569        grid.add(okButton);
570        windowPane.add(mainColumn);
571        return windowPane;
572     }
573     
574     
575     private WindowPane createSimpleWindow(String JavaDoc name) {
576         WindowPane windowPane = new WindowPane();
577         positionWindowPane(windowPane);
578         windowPane.setTitle(name + " Window #" + windowNumber++);
579         windowPane.setTitleInsets(new Insets(10, 5));
580         windowPane.setInsets(new Insets(10));
581         windowPane.setWidth(new Extent(500));
582         windowPane.setHeight(new Extent(280));
583         windowPane.setStyleName("Default");
584         windowPane.add(new Label(StyleUtil.QUASI_LATIN_TEXT_1));
585         return windowPane;
586     }
587     
588     /**
589      * Creates a 'Test Window' that contains buttons which may be used to
590      * configure various aspects of the window.
591      *
592      * @param name the window name
593      * @return the created window
594      */

595     private WindowPane createTestWindow(String JavaDoc name) {
596         final WindowPane windowPane = new WindowPane();
597         positionWindowPane(windowPane);
598         windowPane.setTitle(name + " Window #" + windowNumber++);
599         windowPane.setTitleInsets(new Insets(10, 5));
600         windowPane.setTitleBackground(new Color(0x2f2f4f));
601         windowPane.setInsets(new Insets(10));
602         windowPane.setWidth(new Extent(500));
603         windowPane.setHeight(new Extent(280));
604         windowPane.setStyleName("Default");
605         
606         ButtonColumn column = new ButtonColumn();
607         windowPane.add(column);
608         
609         column.addButton("Set Icon", new ActionListener() {
610             public void actionPerformed(ActionEvent e) {
611                 windowPane.setIcon(Styles.ICON_24_MAIL_COMPOSE);
612                 windowPane.setIconInsets(new Insets(4, 2));
613             }
614         });
615         
616         column.addButton("Clear Icon", new ActionListener() {
617             public void actionPerformed(ActionEvent e) {
618                 windowPane.setIcon(null);
619                 windowPane.setIconInsets(null);
620             }
621         });
622         
623         column.addButton("Set Close Icon (and appropriate Icon Insets)", new ActionListener() {
624             public void actionPerformed(ActionEvent e) {
625                 windowPane.setCloseIcon(Styles.ICON_24_NO);
626                 windowPane.setCloseIconInsets(new Insets(4, 2));
627             }
628         });
629         
630         column.addButton("Clear Close Icon", new ActionListener() {
631             public void actionPerformed(ActionEvent e) {
632                 windowPane.setCloseIcon(null);
633                 windowPane.setCloseIconInsets(null);
634             }
635         });
636         
637         column.addButton("Set Style Name = Default", new ActionListener() {
638             public void actionPerformed(ActionEvent e) {
639                 windowPane.setStyleName("Default");
640             }
641         });
642         
643         column.addButton("Clear Style Name", new ActionListener() {
644             public void actionPerformed(ActionEvent e) {
645                 windowPane.setStyleName(null);
646             }
647         });
648         
649         return windowPane;
650     }
651     
652     private void positionWindowPane(WindowPane windowPane) {
653         Extent positionExtent = new Extent(nextPosition, Extent.PX);
654         windowPane.setPositionX(positionExtent);
655         windowPane.setPositionY(positionExtent);
656         nextPosition += 20;
657         if (nextPosition > 200) {
658             nextPosition = 0;
659         }
660     }
661 }
662
Popular Tags