Source Code Cross Referenced for GridTest.java in  » Ajax » NextApp-Echo2 » nextapp » echo2 » testapp » interactive » testscreen » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » NextApp Echo2 » nextapp.echo2.testapp.interactive.testscreen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package nextapp.echo2.testapp.interactive.testscreen;
031:
032:        import nextapp.echo2.app.Alignment;
033:        import nextapp.echo2.app.Border;
034:        import nextapp.echo2.app.Button;
035:        import nextapp.echo2.app.Color;
036:        import nextapp.echo2.app.Extent;
037:        import nextapp.echo2.app.Grid;
038:        import nextapp.echo2.app.Insets;
039:        import nextapp.echo2.app.Label;
040:        import nextapp.echo2.app.Column;
041:        import nextapp.echo2.app.SplitPane;
042:        import nextapp.echo2.app.event.ActionEvent;
043:        import nextapp.echo2.app.event.ActionListener;
044:        import nextapp.echo2.app.layout.GridLayoutData;
045:        import nextapp.echo2.testapp.interactive.ButtonColumn;
046:        import nextapp.echo2.testapp.interactive.StyleUtil;
047:        import nextapp.echo2.testapp.interactive.Styles;
048:
049:        /**
050:         * Interactive test for <code>Grid</code> components.
051:         */
052:        public class GridTest extends SplitPane {
053:
054:            private int nextCellNumber = 0;
055:            private Button selectedButton;
056:
057:            private ActionListener cellButtonActionListener = new ActionListener() {
058:                public void actionPerformed(ActionEvent e) {
059:                    Button button = (Button) e.getSource();
060:                    selectCellButton(button);
061:                }
062:            };
063:
064:            public GridTest() {
065:                super (SplitPane.ORIENTATION_HORIZONTAL, new Extent(250,
066:                        Extent.PX));
067:                setStyleName("DefaultResizable");
068:
069:                Column groupContainerColumn = new Column();
070:                groupContainerColumn.setCellSpacing(new Extent(5));
071:                groupContainerColumn.setStyleName("TestControlsColumn");
072:                add(groupContainerColumn);
073:
074:                Column testColumn = new Column();
075:                add(testColumn);
076:
077:                ButtonColumn controlsColumn;
078:
079:                controlsColumn = new ButtonColumn();
080:                controlsColumn.add(new Label("Insert/Delete Cells"));
081:                groupContainerColumn.add(controlsColumn);
082:
083:                final Grid grid = new Grid(4);
084:                grid.setBorder(new Border(new Extent(1), Color.BLUE,
085:                        Border.STYLE_SOLID));
086:                while (nextCellNumber < 17) {
087:                    grid.add(createGridCellButton());
088:                }
089:                testColumn.add(grid);
090:
091:                controlsColumn.addButton("Clear Selection",
092:                        new ActionListener() {
093:                            public void actionPerformed(ActionEvent e) {
094:                                selectCellButton(null);
095:                            }
096:                        });
097:
098:                controlsColumn.addButton("Insert Cell Before Selected",
099:                        new ActionListener() {
100:                            public void actionPerformed(ActionEvent e) {
101:                                if (selectedButton != null) {
102:                                    grid.add(createGridCellButton(), grid
103:                                            .indexOf(selectedButton));
104:                                }
105:                            }
106:                        });
107:
108:                controlsColumn.addButton("Append New Cell",
109:                        new ActionListener() {
110:                            public void actionPerformed(ActionEvent e) {
111:                                Button button = createGridCellButton();
112:                                grid.add(button);
113:                                selectCellButton(button);
114:                            }
115:                        });
116:
117:                controlsColumn.addButton("Append 10 New Cells",
118:                        new ActionListener() {
119:                            public void actionPerformed(ActionEvent e) {
120:                                Button button = null;
121:                                for (int i = 0; i < 10; ++i) {
122:                                    button = createGridCellButton();
123:                                    grid.add(button);
124:                                }
125:                                selectCellButton(button);
126:                            }
127:                        });
128:
129:                controlsColumn.addButton("Delete Selected Cell",
130:                        new ActionListener() {
131:                            public void actionPerformed(ActionEvent e) {
132:                                if (selectedButton != null) {
133:                                    int index = grid.indexOf(selectedButton);
134:                                    grid.remove(selectedButton);
135:                                    if (grid.getComponentCount() != 0) {
136:                                        if (index < grid.getComponentCount()) {
137:                                            selectCellButton((Button) grid
138:                                                    .getComponent(index));
139:                                        } else {
140:                                            selectCellButton((Button) grid
141:                                                    .getComponent(grid
142:                                                            .getComponentCount() - 1));
143:                                        }
144:                                    } else {
145:                                        selectCellButton(null);
146:                                    }
147:                                }
148:                            }
149:                        });
150:
151:                controlsColumn = new ButtonColumn();
152:                controlsColumn.add(new Label("Configure Grid"));
153:                groupContainerColumn.add(controlsColumn);
154:
155:                controlsColumn.addButton("Swap Orientation",
156:                        new ActionListener() {
157:                            public void actionPerformed(ActionEvent e) {
158:                                grid
159:                                        .setOrientation(grid.getOrientation() == Grid.ORIENTATION_VERTICAL ? Grid.ORIENTATION_HORIZONTAL
160:                                                : Grid.ORIENTATION_VERTICAL);
161:                            }
162:                        });
163:
164:                controlsColumn.addButton("[+] Size", new ActionListener() {
165:                    public void actionPerformed(ActionEvent e) {
166:                        grid.setSize(grid.getSize() + 1);
167:                    }
168:                });
169:
170:                controlsColumn.addButton("[-] Size", new ActionListener() {
171:                    public void actionPerformed(ActionEvent e) {
172:                        if (grid.getSize() > 1) {
173:                            grid.setSize(grid.getSize() - 1);
174:                        }
175:                    }
176:                });
177:                controlsColumn.addButton("Change Foreground",
178:                        new ActionListener() {
179:                            public void actionPerformed(ActionEvent e) {
180:                                grid.setForeground(StyleUtil.randomColor());
181:                            }
182:                        });
183:                controlsColumn.addButton("Change Background",
184:                        new ActionListener() {
185:                            public void actionPerformed(ActionEvent e) {
186:                                grid.setBackground(StyleUtil.randomColor());
187:                            }
188:                        });
189:                controlsColumn.addButton("Change Border (All Attributes)",
190:                        new ActionListener() {
191:                            public void actionPerformed(ActionEvent e) {
192:                                grid.setBorder(StyleUtil.randomBorder());
193:                            }
194:                        });
195:                controlsColumn.addButton("Change Border Color",
196:                        new ActionListener() {
197:                            public void actionPerformed(ActionEvent e) {
198:                                Border border = grid.getBorder();
199:                                grid.setBorder(new Border(border.getSize(),
200:                                        StyleUtil.randomColor(), border
201:                                                .getStyle()));
202:                            }
203:                        });
204:                controlsColumn.addButton("Change Border Size",
205:                        new ActionListener() {
206:                            public void actionPerformed(ActionEvent e) {
207:                                grid.setBorder(StyleUtil.nextBorderSize(grid
208:                                        .getBorder()));
209:                            }
210:                        });
211:                controlsColumn.addButton("Change Border Style",
212:                        new ActionListener() {
213:                            public void actionPerformed(ActionEvent e) {
214:                                grid.setBorder(StyleUtil.nextBorderStyle(grid
215:                                        .getBorder()));
216:                            }
217:                        });
218:
219:                controlsColumn.addButton("Set Insets 0px",
220:                        new ActionListener() {
221:                            public void actionPerformed(ActionEvent e) {
222:                                grid.setInsets(new Insets(0));
223:                            }
224:                        });
225:                controlsColumn.addButton("Set Insets 2px",
226:                        new ActionListener() {
227:                            public void actionPerformed(ActionEvent e) {
228:                                grid.setInsets(new Insets(2));
229:                            }
230:                        });
231:                controlsColumn.addButton("Set Insets 10/5px",
232:                        new ActionListener() {
233:                            public void actionPerformed(ActionEvent e) {
234:                                grid.setInsets(new Insets(10, 5));
235:                            }
236:                        });
237:                controlsColumn.addButton("Set Insets 10/20/30/40px",
238:                        new ActionListener() {
239:                            public void actionPerformed(ActionEvent e) {
240:                                grid.setInsets(new Insets(10, 20, 30, 40));
241:                            }
242:                        });
243:                controlsColumn.addButton("Set Width = null",
244:                        new ActionListener() {
245:                            public void actionPerformed(ActionEvent e) {
246:                                grid.setWidth(null);
247:                            }
248:                        });
249:                controlsColumn.addButton("Set Width = 500px",
250:                        new ActionListener() {
251:                            public void actionPerformed(ActionEvent e) {
252:                                grid.setWidth(new Extent(500));
253:                            }
254:                        });
255:                controlsColumn.addButton("Set Width = 100%",
256:                        new ActionListener() {
257:                            public void actionPerformed(ActionEvent e) {
258:                                grid.setWidth(new Extent(100, Extent.PERCENT));
259:                            }
260:                        });
261:
262:                controlsColumn = new ButtonColumn();
263:                controlsColumn.add(new Label("Configure Cell"));
264:                groupContainerColumn.add(controlsColumn);
265:
266:                controlsColumn.addButton("[+] Column Span",
267:                        new ActionListener() {
268:                            public void actionPerformed(ActionEvent e) {
269:                                if (selectedButton != null) {
270:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
271:                                            .getLayoutData();
272:                                    if (layoutData.getColumnSpan() < 1) {
273:                                        layoutData.setColumnSpan(1);
274:                                    } else {
275:                                        layoutData.setColumnSpan(layoutData
276:                                                .getColumnSpan() + 1);
277:                                    }
278:                                    selectedButton.setLayoutData(layoutData);
279:                                    retitle(selectedButton);
280:                                }
281:                            }
282:                        });
283:
284:                controlsColumn.addButton("[-] Column Span",
285:                        new ActionListener() {
286:                            public void actionPerformed(ActionEvent e) {
287:                                if (selectedButton != null) {
288:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
289:                                            .getLayoutData();
290:                                    if (layoutData.getColumnSpan() > 1) {
291:                                        layoutData.setColumnSpan(layoutData
292:                                                .getColumnSpan() - 1);
293:                                    } else {
294:                                        layoutData.setColumnSpan(1);
295:                                    }
296:                                    selectedButton.setLayoutData(layoutData);
297:                                    retitle(selectedButton);
298:                                }
299:                            }
300:                        });
301:
302:                controlsColumn.addButton("[+] Row Span", new ActionListener() {
303:                    public void actionPerformed(ActionEvent e) {
304:                        if (selectedButton != null) {
305:                            GridLayoutData layoutData = (GridLayoutData) selectedButton
306:                                    .getLayoutData();
307:                            if (layoutData.getRowSpan() < 1) {
308:                                layoutData.setRowSpan(1);
309:                            } else {
310:                                layoutData
311:                                        .setRowSpan(layoutData.getRowSpan() + 1);
312:                            }
313:                            selectedButton.setLayoutData(layoutData);
314:                            retitle(selectedButton);
315:                        }
316:                    }
317:                });
318:
319:                controlsColumn.addButton("[-] Row Span", new ActionListener() {
320:                    public void actionPerformed(ActionEvent e) {
321:                        if (selectedButton != null) {
322:                            GridLayoutData layoutData = (GridLayoutData) selectedButton
323:                                    .getLayoutData();
324:                            if (layoutData.getRowSpan() > 1) {
325:                                layoutData
326:                                        .setRowSpan(layoutData.getRowSpan() - 1);
327:                            } else {
328:                                layoutData.setRowSpan(1);
329:                            }
330:                            selectedButton.setLayoutData(layoutData);
331:                            retitle(selectedButton);
332:                        }
333:                    }
334:                });
335:
336:                controlsColumn.addButton("Column Span: FILL",
337:                        new ActionListener() {
338:                            public void actionPerformed(ActionEvent e) {
339:                                if (selectedButton != null) {
340:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
341:                                            .getLayoutData();
342:                                    layoutData
343:                                            .setColumnSpan(GridLayoutData.SPAN_FILL);
344:                                    selectedButton.setLayoutData(layoutData);
345:                                    retitle(selectedButton);
346:                                }
347:                            }
348:                        });
349:
350:                controlsColumn.addButton("Row Span: FILL",
351:                        new ActionListener() {
352:                            public void actionPerformed(ActionEvent e) {
353:                                if (selectedButton != null) {
354:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
355:                                            .getLayoutData();
356:                                    layoutData
357:                                            .setRowSpan(GridLayoutData.SPAN_FILL);
358:                                    selectedButton.setLayoutData(layoutData);
359:                                    retitle(selectedButton);
360:                                }
361:                            }
362:                        });
363:
364:                controlsColumn.addButton("Set Insets 0px",
365:                        new ActionListener() {
366:                            public void actionPerformed(ActionEvent e) {
367:                                if (selectedButton != null) {
368:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
369:                                            .getLayoutData();
370:                                    layoutData.setInsets(new Insets(0));
371:                                    selectedButton.setLayoutData(layoutData);
372:                                }
373:                            }
374:                        });
375:                controlsColumn.addButton("Set Insets 2px",
376:                        new ActionListener() {
377:                            public void actionPerformed(ActionEvent e) {
378:                                if (selectedButton != null) {
379:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
380:                                            .getLayoutData();
381:                                    layoutData.setInsets(new Insets(2));
382:                                    selectedButton.setLayoutData(layoutData);
383:                                }
384:                            }
385:                        });
386:                controlsColumn.addButton("Set Insets 10/5px",
387:                        new ActionListener() {
388:                            public void actionPerformed(ActionEvent e) {
389:                                if (selectedButton != null) {
390:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
391:                                            .getLayoutData();
392:                                    layoutData.setInsets(new Insets(10, 5));
393:                                    selectedButton.setLayoutData(layoutData);
394:                                }
395:                            }
396:                        });
397:                controlsColumn.addButton("Set Insets 10/20/30/40px",
398:                        new ActionListener() {
399:                            public void actionPerformed(ActionEvent e) {
400:                                if (selectedButton != null) {
401:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
402:                                            .getLayoutData();
403:                                    layoutData.setInsets(new Insets(10, 20, 30,
404:                                            40));
405:                                    selectedButton.setLayoutData(layoutData);
406:                                }
407:                            }
408:                        });
409:                controlsColumn.addButton("Set Alignment = Default",
410:                        new ActionListener() {
411:                            public void actionPerformed(ActionEvent e) {
412:                                if (selectedButton != null) {
413:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
414:                                            .getLayoutData();
415:                                    layoutData.setAlignment(null);
416:                                    selectedButton.setLayoutData(layoutData);
417:                                }
418:                            }
419:                        });
420:                controlsColumn.addButton("Set Alignment = Leading/Top",
421:                        new ActionListener() {
422:                            public void actionPerformed(ActionEvent e) {
423:                                if (selectedButton != null) {
424:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
425:                                            .getLayoutData();
426:                                    layoutData.setAlignment(new Alignment(
427:                                            Alignment.LEADING, Alignment.TOP));
428:                                    selectedButton.setLayoutData(layoutData);
429:                                }
430:                            }
431:                        });
432:                controlsColumn.addButton("Set Alignment = Trailing/Bottom",
433:                        new ActionListener() {
434:                            public void actionPerformed(ActionEvent e) {
435:                                if (selectedButton != null) {
436:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
437:                                            .getLayoutData();
438:                                    layoutData.setAlignment(new Alignment(
439:                                            Alignment.TRAILING,
440:                                            Alignment.BOTTOM));
441:                                    selectedButton.setLayoutData(layoutData);
442:                                }
443:                            }
444:                        });
445:                controlsColumn.addButton("Set Alignment = Left/Top",
446:                        new ActionListener() {
447:                            public void actionPerformed(ActionEvent e) {
448:                                if (selectedButton != null) {
449:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
450:                                            .getLayoutData();
451:                                    layoutData.setAlignment(new Alignment(
452:                                            Alignment.LEFT, Alignment.TOP));
453:                                    selectedButton.setLayoutData(layoutData);
454:                                }
455:                            }
456:                        });
457:                controlsColumn.addButton("Set Alignment = Right/Bottom",
458:                        new ActionListener() {
459:                            public void actionPerformed(ActionEvent e) {
460:                                if (selectedButton != null) {
461:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
462:                                            .getLayoutData();
463:                                    layoutData.setAlignment(new Alignment(
464:                                            Alignment.RIGHT, Alignment.BOTTOM));
465:                                    selectedButton.setLayoutData(layoutData);
466:                                }
467:                            }
468:                        });
469:                controlsColumn.addButton("Set Alignment = Center/Center",
470:                        new ActionListener() {
471:                            public void actionPerformed(ActionEvent e) {
472:                                if (selectedButton != null) {
473:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
474:                                            .getLayoutData();
475:                                    layoutData
476:                                            .setAlignment(new Alignment(
477:                                                    Alignment.CENTER,
478:                                                    Alignment.CENTER));
479:                                    selectedButton.setLayoutData(layoutData);
480:                                }
481:                            }
482:                        });
483:                controlsColumn.addButton("Set BackgroundImage",
484:                        new ActionListener() {
485:                            public void actionPerformed(ActionEvent e) {
486:                                if (selectedButton != null) {
487:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
488:                                            .getLayoutData();
489:                                    layoutData
490:                                            .setBackgroundImage(Styles.BG_SHADOW_DARK_BLUE);
491:                                    selectedButton.setLayoutData(layoutData);
492:                                }
493:                            }
494:                        });
495:                controlsColumn.addButton("Clear BackgroundImage",
496:                        new ActionListener() {
497:                            public void actionPerformed(ActionEvent e) {
498:                                if (selectedButton != null) {
499:                                    GridLayoutData layoutData = (GridLayoutData) selectedButton
500:                                            .getLayoutData();
501:                                    layoutData.setBackgroundImage(null);
502:                                    selectedButton.setLayoutData(layoutData);
503:                                }
504:                            }
505:                        });
506:
507:                controlsColumn = new ButtonColumn();
508:                controlsColumn.add(new Label("Configure Rows/Columns"));
509:                groupContainerColumn.add(controlsColumn);
510:
511:                controlsColumn.addButton("Clear Widths of First 16 Columns",
512:                        new ActionListener() {
513:                            public void actionPerformed(ActionEvent e) {
514:                                for (int i = 0; i < 16; ++i) {
515:                                    grid.setColumnWidth(i, null);
516:                                }
517:                            }
518:                        });
519:
520:                controlsColumn.addButton("Set First 16 Columns to 100px Width",
521:                        new ActionListener() {
522:                            public void actionPerformed(ActionEvent e) {
523:                                Extent width = new Extent(100);
524:                                for (int i = 0; i < 16; ++i) {
525:                                    grid.setColumnWidth(i, width);
526:                                }
527:                            }
528:                        });
529:
530:                controlsColumn.addButton(
531:                        "Set First 16 Columns to Random Width",
532:                        new ActionListener() {
533:                            public void actionPerformed(ActionEvent e) {
534:                                for (int i = 0; i < 16; ++i) {
535:                                    grid
536:                                            .setColumnWidth(
537:                                                    i,
538:                                                    new Extent(
539:                                                            ((int) (Math
540:                                                                    .random() * 100)) + 50));
541:                                }
542:                            }
543:                        });
544:
545:                controlsColumn.addButton("Clear Heights of First 16 Rows",
546:                        new ActionListener() {
547:                            public void actionPerformed(ActionEvent e) {
548:                                for (int i = 0; i < 16; ++i) {
549:                                    grid.setRowHeight(i, null);
550:                                }
551:                            }
552:                        });
553:
554:                controlsColumn.addButton("Set First 16 Rows to 100px Height",
555:                        new ActionListener() {
556:                            public void actionPerformed(ActionEvent e) {
557:                                Extent height = new Extent(100);
558:                                for (int i = 0; i < 16; ++i) {
559:                                    grid.setRowHeight(i, height);
560:                                }
561:                            }
562:                        });
563:
564:                controlsColumn.addButton("Set First 16 Rows to Random Height",
565:                        new ActionListener() {
566:                            public void actionPerformed(ActionEvent e) {
567:                                for (int i = 0; i < 16; ++i) {
568:                                    grid
569:                                            .setRowHeight(
570:                                                    i,
571:                                                    new Extent(
572:                                                            ((int) (Math
573:                                                                    .random() * 100)) + 50));
574:                                }
575:                            }
576:                        });
577:            }
578:
579:            public Button createGridCellButton() {
580:                Button button = new Button("Grid Cell #" + nextCellNumber++);
581:                GridLayoutData layoutData = new GridLayoutData();
582:                button.setLayoutData(layoutData);
583:                button.addActionListener(cellButtonActionListener);
584:                return button;
585:            }
586:
587:            private void retitle(Button button) {
588:                StringBuffer out = new StringBuffer();
589:                GridLayoutData layoutData = (GridLayoutData) selectedButton
590:                        .getLayoutData();
591:                if (layoutData.getColumnSpan() != 1
592:                        || layoutData.getRowSpan() != 1) {
593:                    out
594:                            .append("["
595:                                    + (layoutData.getColumnSpan() == GridLayoutData.SPAN_FILL ? "F"
596:                                            : Integer.toString(layoutData
597:                                                    .getColumnSpan()))
598:                                    + "x"
599:                                    + (layoutData.getRowSpan() == GridLayoutData.SPAN_FILL ? "F"
600:                                            : Integer.toString(layoutData
601:                                                    .getRowSpan())) + "]");
602:                }
603:                String text = button.getText();
604:                if (text.indexOf(":") == -1) {
605:                    if (out.length() == 0) {
606:                        return;
607:                    }
608:                    text = text + " : " + out;
609:                } else {
610:                    if (out.length() == 0) {
611:                        text = text.substring(0, text.indexOf(":"));
612:                    } else {
613:                        text = text.substring(0, text.indexOf(":") + 2) + out;
614:                    }
615:                }
616:                button.setText(text);
617:            }
618:
619:            private void selectCellButton(Button button) {
620:                GridLayoutData layoutData;
621:                if (selectedButton != null) {
622:                    layoutData = (GridLayoutData) selectedButton
623:                            .getLayoutData();
624:                    layoutData.setBackground(null);
625:                    selectedButton.setLayoutData(layoutData);
626:                }
627:                if (button != null) {
628:                    layoutData = (GridLayoutData) button.getLayoutData();
629:                    layoutData.setBackground(new Color(0xefefaf));
630:                    button.setLayoutData(layoutData);
631:                }
632:                selectedButton = button;
633:            }
634:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.