Source Code Cross Referenced for ButtonBarFactory.java in  » Swing-Library » jgoodies-forms » com » jgoodies » forms » factories » 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 » Swing Library » jgoodies forms » com.jgoodies.forms.factories 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:
031:        package com.jgoodies.forms.factories;
032:
033:        import javax.swing.JButton;
034:        import javax.swing.JPanel;
035:
036:        import com.jgoodies.forms.builder.ButtonBarBuilder;
037:
038:        /**
039:         * A factory class that consists only of static methods to build frequently used 
040:         * button bars. Utilizes the {@link com.jgoodies.forms.builder.ButtonBarBuilder} 
041:         * that in turn uses the {@link com.jgoodies.forms.layout.FormLayout} 
042:         * to lay out the bars.<p>
043:         * 
044:         * The button bars returned by this builder comply with popular UI style guides.
045:         *
046:         * @author Karsten Lentzsch
047:         * @version $Revision: 1.2 $
048:         * 
049:         * @see com.jgoodies.forms.builder.ButtonBarBuilder
050:         * @see com.jgoodies.forms.util.LayoutStyle
051:         */
052:
053:        public final class ButtonBarFactory {
054:
055:            private ButtonBarFactory() {
056:                // Suppresses default constructor, ensuring non-instantiability.
057:            }
058:
059:            // General Purpose Factory Methods: Left Aligned ************************
060:
061:            /**
062:             * Builds and returns a left aligned bar with one button.
063:             * 
064:             * @param button1  the first button to add
065:             * @return a button bar with the given button
066:             */
067:            public static JPanel buildLeftAlignedBar(JButton button1) {
068:                return buildLeftAlignedBar(new JButton[] { button1 });
069:            }
070:
071:            /**
072:             * Builds and returns a left aligned bar with two buttons.
073:             * 
074:             * @param button1  the first button to add
075:             * @param button2  the second button to add
076:             * @return a button bar with the given buttons
077:             */
078:            public static JPanel buildLeftAlignedBar(JButton button1,
079:                    JButton button2) {
080:                return buildLeftAlignedBar(new JButton[] { button1, button2 },
081:                        true);
082:            }
083:
084:            /**
085:             * Builds and returns a left aligned bar with three buttons.
086:             * 
087:             * @param button1  the first button to add
088:             * @param button2  the second button to add
089:             * @param button3  the third button to add
090:             * @return a button bar with the given buttons
091:             */
092:            public static JPanel buildLeftAlignedBar(JButton button1,
093:                    JButton button2, JButton button3) {
094:                return buildLeftAlignedBar(new JButton[] { button1, button2,
095:                        button3 }, true);
096:            }
097:
098:            /**
099:             * Builds and returns a left aligned bar with four buttons.
100:             * 
101:             * @param button1  the first button to add
102:             * @param button2  the second button to add
103:             * @param button3  the third button to add
104:             * @param button4  the fourth button to add
105:             * @return a button bar with the given buttons
106:             */
107:            public static JPanel buildLeftAlignedBar(JButton button1,
108:                    JButton button2, JButton button3, JButton button4) {
109:                return buildLeftAlignedBar(new JButton[] { button1, button2,
110:                        button3, button4 }, true);
111:            }
112:
113:            /**
114:             * Builds and returns a left aligned bar with five buttons.
115:             * 
116:             * @param button1  the first button to add
117:             * @param button2  the second button to add
118:             * @param button3  the third button to add
119:             * @param button4  the fourth button to add
120:             * @param button5  the fifth button to add
121:             * @return a button bar with the given buttons
122:             */
123:            public static JPanel buildLeftAlignedBar(JButton button1,
124:                    JButton button2, JButton button3, JButton button4,
125:                    JButton button5) {
126:                return buildLeftAlignedBar(new JButton[] { button1, button2,
127:                        button3, button4, button5 }, true);
128:            }
129:
130:            /**
131:             * Builds and returns a left aligned button bar with the given buttons.
132:             * 
133:             * @param buttons  an array of buttons to add
134:             * @return a left aligned button bar with the given buttons
135:             */
136:            public static JPanel buildLeftAlignedBar(JButton[] buttons) {
137:                ButtonBarBuilder builder = new ButtonBarBuilder();
138:                builder.addGriddedButtons(buttons);
139:                builder.addGlue();
140:                return builder.getPanel();
141:            }
142:
143:            /**
144:             * Builds and returns a left aligned button bar with the given buttons.
145:             * 
146:             * @param buttons                  an array of buttons to add
147:             * @param leftToRightButtonOrder   the order in which the buttons to add
148:             * @return a left aligned button bar with the given buttons
149:             */
150:            public static JPanel buildLeftAlignedBar(JButton[] buttons,
151:                    boolean leftToRightButtonOrder) {
152:                ButtonBarBuilder builder = new ButtonBarBuilder();
153:                builder.setLeftToRightButtonOrder(leftToRightButtonOrder);
154:                builder.addGriddedButtons(buttons);
155:                builder.addGlue();
156:                return builder.getPanel();
157:            }
158:
159:            // General Purpose Factory Methods: Centered ****************************
160:
161:            /**
162:             * Builds and returns a centered bar with one button.
163:             * 
164:             * @param button1  the first button to add
165:             * @return a button bar with the given button
166:             */
167:            public static JPanel buildCenteredBar(JButton button1) {
168:                return buildCenteredBar(new JButton[] { button1 });
169:            }
170:
171:            /**
172:             * Builds and returns a centered bar with two buttons.
173:             * 
174:             * @param button1  the first button to add
175:             * @param button2  the second button to add
176:             * @return a button bar with the given buttons
177:             */
178:            public static JPanel buildCenteredBar(JButton button1,
179:                    JButton button2) {
180:                return buildCenteredBar(new JButton[] { button1, button2 });
181:            }
182:
183:            /**
184:             * Builds and returns a centered bar with three buttons.
185:             * 
186:             * @param button1  the first button to add
187:             * @param button2  the second button to add
188:             * @param button3  the third button to add
189:             * @return a button bar with the given buttons
190:             */
191:            public static JPanel buildCenteredBar(JButton button1,
192:                    JButton button2, JButton button3) {
193:                return buildCenteredBar(new JButton[] { button1, button2,
194:                        button3 });
195:            }
196:
197:            /**
198:             * Builds and returns a centered bar with four buttons.
199:             * 
200:             * @param button1  the first button to add
201:             * @param button2  the second button to add
202:             * @param button3  the third button to add
203:             * @param button4  the fourth button to add
204:             * @return a button bar with the given buttons
205:             */
206:            public static JPanel buildCenteredBar(JButton button1,
207:                    JButton button2, JButton button3, JButton button4) {
208:                return buildCenteredBar(new JButton[] { button1, button2,
209:                        button3, button4 });
210:            }
211:
212:            /**
213:             * Builds and returns a centered bar with five buttons.
214:             * 
215:             * @param button1  the first button to add
216:             * @param button2  the second button to add
217:             * @param button3  the third button to add
218:             * @param button4  the fourth button to add
219:             * @param button5  the fifth button to add
220:             * @return a button bar with the given buttons
221:             */
222:            public static JPanel buildCenteredBar(JButton button1,
223:                    JButton button2, JButton button3, JButton button4,
224:                    JButton button5) {
225:                return buildCenteredBar(new JButton[] { button1, button2,
226:                        button3, button4, button5 });
227:            }
228:
229:            /**
230:             * Builds and returns a centered button bar with the given buttons.
231:             * 
232:             * @param buttons  an array of buttons to add
233:             * @return a centered button bar with the given buttons
234:             */
235:            public static JPanel buildCenteredBar(JButton[] buttons) {
236:                ButtonBarBuilder builder = new ButtonBarBuilder();
237:                builder.addGlue();
238:                builder.addGriddedButtons(buttons);
239:                builder.addGlue();
240:                return builder.getPanel();
241:            }
242:
243:            /**
244:             * Builds and returns a filled bar with one button.
245:             * 
246:             * @param button1  the first button to add
247:             * @return a button bar with the given button
248:             */
249:            public static JPanel buildGrowingBar(JButton button1) {
250:                return buildGrowingBar(new JButton[] { button1 });
251:            }
252:
253:            /**
254:             * Builds and returns a filled button bar with two buttons.
255:             * 
256:             * @param button1  the first button to add
257:             * @param button2  the second button to add
258:             * @return a button bar with the given buttons
259:             */
260:            public static JPanel buildGrowingBar(JButton button1,
261:                    JButton button2) {
262:                return buildGrowingBar(new JButton[] { button1, button2 });
263:            }
264:
265:            /**
266:             * Builds and returns a filled bar with three buttons.
267:             * 
268:             * @param button1  the first button to add
269:             * @param button2  the second button to add
270:             * @param button3  the third button to add
271:             * @return a button bar with the given buttons
272:             */
273:            public static JPanel buildGrowingBar(JButton button1,
274:                    JButton button2, JButton button3) {
275:                return buildGrowingBar(new JButton[] { button1, button2,
276:                        button3 });
277:            }
278:
279:            /**
280:             * Builds and returns a filled bar with four buttons.
281:             * 
282:             * @param button1  the first button to add
283:             * @param button2  the second button to add
284:             * @param button3  the third button to add
285:             * @param button4  the fourth button to add
286:             * @return a button bar with the given buttons
287:             */
288:            public static JPanel buildGrowingBar(JButton button1,
289:                    JButton button2, JButton button3, JButton button4) {
290:                return buildGrowingBar(new JButton[] { button1, button2,
291:                        button3, button4 });
292:            }
293:
294:            /**
295:             * Builds and returns a filled bar with five buttons.
296:             * 
297:             * @param button1  the first button to add
298:             * @param button2  the second button to add
299:             * @param button3  the third button to add
300:             * @param button4  the fourth button to add
301:             * @param button5  the fifth button to add
302:             * @return a button bar with the given buttons
303:             */
304:            public static JPanel buildGrowingBar(JButton button1,
305:                    JButton button2, JButton button3, JButton button4,
306:                    JButton button5) {
307:                return buildGrowingBar(new JButton[] { button1, button2,
308:                        button3, button4, button5 });
309:            }
310:
311:            /**
312:             * Builds and returns a button bar with the given buttons. All button
313:             * columns will grow with the bar.
314:             * 
315:             * @param buttons  an array of buttons to add
316:             * @return a filled button bar with the given buttons
317:             */
318:            public static JPanel buildGrowingBar(JButton[] buttons) {
319:                ButtonBarBuilder builder = new ButtonBarBuilder();
320:                builder.addGriddedGrowingButtons(buttons);
321:                return builder.getPanel();
322:            }
323:
324:            // General Purpose Factory Methods: Right Aligned ***********************
325:
326:            /**
327:             * Builds and returns a right aligned bar with one button.
328:             * 
329:             * @param button1  the first button to add
330:             * @return a button bar with the given button
331:             */
332:            public static JPanel buildRightAlignedBar(JButton button1) {
333:                return buildRightAlignedBar(new JButton[] { button1 });
334:            }
335:
336:            /**
337:             * Builds and returns a right aligned bar with two buttons.
338:             * 
339:             * @param button1  the first button to add
340:             * @param button2  the second button to add
341:             * @return a button bar with the given buttons
342:             */
343:            public static JPanel buildRightAlignedBar(JButton button1,
344:                    JButton button2) {
345:                return buildRightAlignedBar(new JButton[] { button1, button2 },
346:                        true);
347:            }
348:
349:            /**
350:             * Builds and returns a right aligned bar with three buttons.
351:             * 
352:             * @param button1  the first button to add
353:             * @param button2  the second button to add
354:             * @param button3  the third button to add
355:             * @return a button bar with the given buttons
356:             */
357:            public static JPanel buildRightAlignedBar(JButton button1,
358:                    JButton button2, JButton button3) {
359:                return buildRightAlignedBar(new JButton[] { button1, button2,
360:                        button3 }, true);
361:            }
362:
363:            /**
364:             * Builds and returns a right aligned bar with four buttons.
365:             * 
366:             * @param button1  the first button to add
367:             * @param button2  the second button to add
368:             * @param button3  the third button to add
369:             * @param button4  the fourth button to add
370:             * @return a button bar with the given buttons
371:             */
372:            public static JPanel buildRightAlignedBar(JButton button1,
373:                    JButton button2, JButton button3, JButton button4) {
374:                return buildRightAlignedBar(new JButton[] { button1, button2,
375:                        button3, button4 }, true);
376:            }
377:
378:            /**
379:             * Builds and returns a right aligned bar with five buttons.
380:             * 
381:             * @param button1  the first button to add
382:             * @param button2  the second button to add
383:             * @param button3  the third button to add
384:             * @param button4  the fourth button to add
385:             * @param button5  the fifth button to add
386:             * @return a button bar with the given buttons
387:             */
388:            public static JPanel buildRightAlignedBar(JButton button1,
389:                    JButton button2, JButton button3, JButton button4,
390:                    JButton button5) {
391:                return buildRightAlignedBar(new JButton[] { button1, button2,
392:                        button3, button4, button5 }, true);
393:            }
394:
395:            /**
396:             * Builds and returns a right aligned button bar with the given buttons.
397:             * 
398:             * @param buttons  an array of buttons to add
399:             * @return a right aligned button bar with the given buttons
400:             */
401:            public static JPanel buildRightAlignedBar(JButton[] buttons) {
402:                ButtonBarBuilder builder = new ButtonBarBuilder();
403:                builder.addGlue();
404:                builder.addGriddedButtons(buttons);
405:                return builder.getPanel();
406:            }
407:
408:            /**
409:             * Builds and returns a right aligned button bar with the given buttons.
410:             * 
411:             * @param buttons  an array of buttons to add
412:             * @param leftToRightButtonOrder   the order in which the buttons to add
413:             * @return a right aligned button bar with the given buttons
414:             */
415:            public static JPanel buildRightAlignedBar(JButton[] buttons,
416:                    boolean leftToRightButtonOrder) {
417:                ButtonBarBuilder builder = new ButtonBarBuilder();
418:                builder.setLeftToRightButtonOrder(leftToRightButtonOrder);
419:                builder.addGlue();
420:                builder.addGriddedButtons(buttons);
421:                return builder.getPanel();
422:            }
423:
424:            // Right Aligned Button Bars with Help in the Left **********************    
425:
426:            /**
427:             * Builds and returns a right aligned bar with help and one button.
428:             * 
429:             * @param help     the help button to add on the left side
430:             * @param button1  the first button to add
431:             * @return a button bar with the given buttons
432:             */
433:            public static JPanel buildHelpBar(JButton help, JButton button1) {
434:                return buildHelpBar(help, new JButton[] { button1 });
435:            }
436:
437:            /**
438:             * Builds and returns a right aligned bar with help and two buttons.
439:             * 
440:             * @param help     the help button to add on the left side
441:             * @param button1  the first button to add
442:             * @param button2  the second button to add
443:             * @return a button bar with the given buttons
444:             */
445:            public static JPanel buildHelpBar(JButton help, JButton button1,
446:                    JButton button2) {
447:                return buildHelpBar(help, new JButton[] { button1, button2 });
448:            }
449:
450:            /**
451:             * Builds and returns a right aligned bar with help and three buttons.
452:             * 
453:             * @param help     the help button to add on the left side
454:             * @param button1  the first button to add
455:             * @param button2  the second button to add
456:             * @param button3  the third button to add
457:             * @return a button bar with the given buttons
458:             */
459:            public static JPanel buildHelpBar(JButton help, JButton button1,
460:                    JButton button2, JButton button3) {
461:                return buildHelpBar(help, new JButton[] { button1, button2,
462:                        button3 });
463:            }
464:
465:            /**
466:             * Builds and returns a right aligned bar with help and four buttons.
467:             * 
468:             * @param help     the help button to add on the left side
469:             * @param button1  the first button to add
470:             * @param button2  the second button to add
471:             * @param button3  the third button to add
472:             * @param button4  the fourth button to add
473:             * @return a button bar with the given buttons
474:             */
475:            public static JPanel buildHelpBar(JButton help, JButton button1,
476:                    JButton button2, JButton button3, JButton button4) {
477:                return buildHelpBar(help, new JButton[] { button1, button2,
478:                        button3, button4 });
479:            }
480:
481:            /**
482:             * Builds and returns a right aligned bar with help and other buttons.
483:             * 
484:             * @param help     the help button to add on the left side
485:             * @param buttons  an array of buttons to add
486:             * @return a right aligned button bar with the given buttons
487:             */
488:            public static JPanel buildHelpBar(JButton help, JButton[] buttons) {
489:                ButtonBarBuilder builder = new ButtonBarBuilder();
490:                builder.addGridded(help);
491:                builder.addRelatedGap();
492:                builder.addGlue();
493:                builder.addGriddedButtons(buttons);
494:                return builder.getPanel();
495:            }
496:
497:            // Popular Dialog Button Bars: No Help **********************************    
498:
499:            /**
500:             * Builds and returns a button bar with Close.
501:             * 
502:             * @param close   	the Close button
503:             * @return a panel that contains the button(s)
504:             */
505:            public static JPanel buildCloseBar(JButton close) {
506:                return buildRightAlignedBar(close);
507:            }
508:
509:            /**
510:             * Builds and returns a button bar with OK.
511:             * 
512:             * @param ok   	the OK button
513:             * @return a panel that contains the button(s)
514:             */
515:            public static JPanel buildOKBar(JButton ok) {
516:                return buildRightAlignedBar(ok);
517:            }
518:
519:            /**
520:             * Builds and returns a button bar with OK and Cancel.
521:             * 
522:             * @param ok		the OK button
523:             * @param cancel	the Cancel button
524:             * @return a panel that contains the button(s)
525:             */
526:            public static JPanel buildOKCancelBar(JButton ok, JButton cancel) {
527:                return buildRightAlignedBar(new JButton[] { ok, cancel });
528:            }
529:
530:            /**
531:             * Builds and returns a button bar with OK, Cancel and Apply.
532:             * 
533:             * @param ok        the OK button
534:             * @param cancel    the Cancel button
535:             * @param apply	the Apply button
536:             * @return a panel that contains the button(s)
537:             */
538:            public static JPanel buildOKCancelApplyBar(JButton ok,
539:                    JButton cancel, JButton apply) {
540:                return buildRightAlignedBar(new JButton[] { ok, cancel, apply });
541:            }
542:
543:            // Popular Dialog Button Bars: Help in the Left *************************    
544:
545:            /**
546:             * Builds and returns a button bar with 
547:             * Help and Close.
548:             * 
549:             * @param help     the Help button
550:             * @param close    the Close button
551:             * @return a panel that contains the button(s)
552:             */
553:            public static JPanel buildHelpCloseBar(JButton help, JButton close) {
554:                return buildHelpBar(help, close);
555:            }
556:
557:            /**
558:             * Builds and returns a button bar with 
559:             * Help and OK.
560:             * 
561:             * @param help     the Help button
562:             * @param ok	    the OK button
563:             * @return a panel that contains the button(s)
564:             */
565:            public static JPanel buildHelpOKBar(JButton help, JButton ok) {
566:                return buildHelpBar(help, ok);
567:            }
568:
569:            /**
570:             * Builds and returns a button bar with 
571:             * Help, OK and Cancel.
572:             * 
573:             * @param help     the Help button
574:             * @param ok       the OK button
575:             * @param cancel	the Cancel button
576:             * @return a panel that contains the button(s)
577:             */
578:            public static JPanel buildHelpOKCancelBar(JButton help, JButton ok,
579:                    JButton cancel) {
580:                return buildHelpBar(help, ok, cancel);
581:            }
582:
583:            /**
584:             * Builds and returns a button bar with 
585:             * Help, OK, Cancel and Apply.
586:             * 
587:             * @param help     the Help button
588:             * @param ok       the OK button
589:             * @param cancel   the Cancel button
590:             * @param apply	the Apply button
591:             * @return a panel that contains the button(s)
592:             */
593:            public static JPanel buildHelpOKCancelApplyBar(JButton help,
594:                    JButton ok, JButton cancel, JButton apply) {
595:                return buildHelpBar(help, ok, cancel, apply);
596:            }
597:
598:            // Popular Dialog Button Bars: Help in the Right Hand Side **************    
599:
600:            /**
601:             * Builds and returns a button bar with 
602:             * Close and Help.
603:             * 
604:             * @param close	the Close button
605:             * @param help     the Help button
606:             * @return a panel that contains the button(s)
607:             */
608:            public static JPanel buildCloseHelpBar(JButton close, JButton help) {
609:                return buildRightAlignedBar(new JButton[] { close, help });
610:            }
611:
612:            /**
613:             * Builds and returns a button bar with 
614:             * OK and Help.
615:             * 
616:             * @param ok		the OK button
617:             * @param help     the Help button
618:             * @return a panel that contains the button(s)
619:             */
620:            public static JPanel buildOKHelpBar(JButton ok, JButton help) {
621:                return buildRightAlignedBar(new JButton[] { ok, help });
622:            }
623:
624:            /**
625:             * Builds and returns a button bar with 
626:             * OK, Cancel, and Help.
627:             * 
628:             * @param ok       the OK button
629:             * @param cancel	the Cancel button
630:             * @param help     the Help button
631:             * @return a panel that contains the button(s)
632:             */
633:            public static JPanel buildOKCancelHelpBar(JButton ok,
634:                    JButton cancel, JButton help) {
635:                return buildRightAlignedBar(new JButton[] { ok, cancel, help });
636:            }
637:
638:            /**
639:             * Builds and returns a button bar with 
640:             * OK, Cancel, Apply and Help.
641:             * 
642:             * @param ok       the OK button
643:             * @param cancel	the Cancel button
644:             * @param apply	the Apply button
645:             * @param help     the Help button
646:             * @return a panel that contains the button(s)
647:             */
648:            public static JPanel buildOKCancelApplyHelpBar(JButton ok,
649:                    JButton cancel, JButton apply, JButton help) {
650:                return buildRightAlignedBar(new JButton[] { ok, cancel, apply,
651:                        help });
652:            }
653:
654:            // Add..., Remove *******************************************************
655:
656:            /**
657:             * Builds and returns a left aligned button bar with 
658:             * Add and Remove.
659:             * 
660:             * @param add		the Add button
661:             * @param remove	the Remove button
662:             * @return a panel that contains the button(s)
663:             */
664:            public static JPanel buildAddRemoveLeftBar(JButton add,
665:                    JButton remove) {
666:                return buildLeftAlignedBar(add, remove);
667:            }
668:
669:            /**
670:             * Builds and returns a filled button bar with Add and Remove.
671:             * 
672:             * @param add       the Add button
673:             * @param remove    the Remove button
674:             * @return a panel that contains the button(s)
675:             */
676:            public static JPanel buildAddRemoveBar(JButton add, JButton remove) {
677:                return buildGrowingBar(add, remove);
678:            }
679:
680:            /**
681:             * Builds and returns a right aligned button bar with 
682:             * Add and Remove.
683:             * 
684:             * @param add       the Add button
685:             * @param remove    the Remove button
686:             * @return a panel that contains the button(s)
687:             */
688:            public static JPanel buildAddRemoveRightBar(JButton add,
689:                    JButton remove) {
690:                return buildRightAlignedBar(add, remove);
691:            }
692:
693:            // Add..., Remove, Properties... ****************************************
694:
695:            /**
696:             * Builds and returns a left aligned button bar with 
697:             * Add, Remove, and Properties.
698:             * 
699:             * @param add       	the Add button
700:             * @param remove    	the Remove button
701:             * @param properties	the Properties button
702:             * @return a panel that contains the button(s)
703:             */
704:            public static JPanel buildAddRemovePropertiesLeftBar(JButton add,
705:                    JButton remove, JButton properties) {
706:                return buildLeftAlignedBar(add, remove, properties);
707:            }
708:
709:            /**
710:             * Builds and returns a filled button bar with Add, Remove, and
711:             * Properties.
712:             * 
713:             * @param add           the Add button
714:             * @param remove        the Remove button
715:             * @param properties    the Properties button
716:             * @return a panel that contains the button(s)
717:             */
718:            public static JPanel buildAddRemovePropertiesBar(JButton add,
719:                    JButton remove, JButton properties) {
720:                ButtonBarBuilder builder = new ButtonBarBuilder();
721:                builder.addGriddedGrowing(add);
722:                builder.addRelatedGap();
723:                builder.addGriddedGrowing(remove);
724:                builder.addRelatedGap();
725:                builder.addGriddedGrowing(properties);
726:                return builder.getPanel();
727:            }
728:
729:            /**
730:             * Builds and returns a right aligned button bar with 
731:             * Add, Remove, and Properties.
732:             * 
733:             * @param add           the Add button
734:             * @param remove        the Remove button
735:             * @param properties    the Properties button
736:             * @return a panel that contains the button(s)
737:             */
738:            public static JPanel buildAddRemovePropertiesRightBar(JButton add,
739:                    JButton remove, JButton properties) {
740:                return buildRightAlignedBar(add, remove, properties);
741:            }
742:
743:            // Wizard Bars **********************************************************
744:
745:            /**
746:             * Builds and returns a wizard button bar with:
747:             * Back, Next, Finish, Cancel.
748:             *
749:             * @param back		the Back button
750:             * @param next		the Next button
751:             * @param finish	the Finish button
752:             * @param cancel	the Cancel button
753:             * @return a wizard button bar for back, next, finish, cancel
754:             */
755:            public static JPanel buildWizardBar(JButton back, JButton next,
756:                    JButton finish, JButton cancel) {
757:                return buildWizardBar(back, next, new JButton[] { finish,
758:                        cancel });
759:            }
760:
761:            /**
762:             * Builds and returns a wizard button bar with: 
763:             * Help and Back, Next, Finish, Cancel.
764:             * 
765:             * @param help		the Help button
766:             * @param back      the Back button
767:             * @param next      the Next button
768:             * @param finish    the Finish button
769:             * @param cancel    the Cancel button
770:             * @return a wizard button bar for help, back, next, finish, cancel
771:             */
772:            public static JPanel buildWizardBar(JButton help, JButton back,
773:                    JButton next, JButton finish, JButton cancel) {
774:                return buildWizardBar(new JButton[] { help }, back, next,
775:                        new JButton[] { finish, cancel });
776:            }
777:
778:            /**
779:             * Builds and returns a wizard button bar that consists of the back and
780:             * next buttons, and some right aligned buttons.
781:             * 
782:             * @param back                the mandatory back button
783:             * @param next                the mandatory next button
784:             * @param rightAlignedButtons an optional array of buttons that will be
785:             *      located in the bar's right hand side
786:             * @return a wizard button bar with back, next and a bunch of buttons
787:             */
788:            public static JPanel buildWizardBar(JButton back, JButton next,
789:                    JButton[] rightAlignedButtons) {
790:                return buildWizardBar(null, back, next, rightAlignedButtons);
791:            }
792:
793:            /**
794:             * Builds and returns a wizard button bar. It consists of some left
795:             * aligned buttons, the back and next buttons, and some right aligned
796:             * buttons. 
797:             * 
798:             * @param leftAlignedButtons  an optional array of buttons that will be
799:             *     positioned in the bar's left hand side
800:             * @param back                the mandatory back button
801:             * @param next                the mandatory next button
802:             * @param rightAlignedButtons an optional array of buttons that will be
803:             *     located in the bar's right hand side
804:             * @return a wizard button bar with back, next and a bunch of buttons
805:             */
806:            public static JPanel buildWizardBar(JButton[] leftAlignedButtons,
807:                    JButton back, JButton next, JButton[] rightAlignedButtons) {
808:                return buildWizardBar(leftAlignedButtons, back, next, null,
809:                        rightAlignedButtons);
810:            }
811:
812:            /**
813:             * Builds and returns a wizard button bar. It consists of some left
814:             * aligned buttons, the back, next group, and some right aligned buttons.
815:             * To allow the finish button to overlay the next button, you can
816:             * optionally provide the <code>overlayedFinish</code> parameter.
817:             * 
818:             * @param leftAlignedButtons  an optional array of buttons that will be
819:             *     positioned in the bar's left hand side
820:             * @param back                the mandatory back button
821:             * @param next                the mandatory next button
822:             * @param overlayedFinish     the optional overlayed finish button
823:             * @param rightAlignedButtons an optional array of buttons that will be
824:             *     located in the bar's right hand side
825:             * @return a wizard button bar with back, next and a bunch of buttons
826:             */
827:            public static JPanel buildWizardBar(JButton[] leftAlignedButtons,
828:                    JButton back, JButton next, JButton overlayedFinish,
829:                    JButton[] rightAlignedButtons) {
830:
831:                ButtonBarBuilder builder = new ButtonBarBuilder();
832:                if (leftAlignedButtons != null) {
833:                    builder.addGriddedButtons(leftAlignedButtons);
834:                    builder.addRelatedGap();
835:                }
836:                builder.addGlue();
837:                builder.addGridded(back);
838:                builder.addGridded(next);
839:
840:                // Optionally overlay the finish and next button.
841:                if (overlayedFinish != null) {
842:                    builder.nextColumn(-1);
843:                    builder.add(overlayedFinish);
844:                    builder.nextColumn();
845:                }
846:
847:                if (rightAlignedButtons != null) {
848:                    builder.addRelatedGap();
849:                    builder.addGriddedButtons(rightAlignedButtons);
850:                }
851:                return builder.getPanel();
852:            }
853:
854:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.