1 30 31 package com.jgoodies.forms.factories; 32 33 import javax.swing.JButton ; 34 import javax.swing.JPanel ; 35 36 import com.jgoodies.forms.builder.ButtonBarBuilder; 37 38 49 50 public final class ButtonBarFactory { 51 52 private ButtonBarFactory() { 53 } 55 56 57 59 65 public static JPanel buildLeftAlignedBar(JButton button1) { 66 return buildLeftAlignedBar(new JButton []{ 67 button1 68 }); 69 } 70 71 78 public static JPanel buildLeftAlignedBar( 79 JButton button1, JButton button2) { 80 return buildLeftAlignedBar(new JButton []{ 81 button1, button2 82 }); 83 } 84 85 93 public static JPanel buildLeftAlignedBar( 94 JButton button1, JButton button2, JButton button3) { 95 return buildLeftAlignedBar(new JButton []{ 96 button1, button2, button3 97 }); 98 } 99 100 109 public static JPanel buildLeftAlignedBar( 110 JButton button1, JButton button2, JButton button3, JButton button4) { 111 return buildLeftAlignedBar(new JButton []{ 112 button1, button2, button3, button4 113 }); 114 } 115 116 126 public static JPanel buildLeftAlignedBar( 127 JButton button1, JButton button2, JButton button3, 128 JButton button4, JButton button5) { 129 return buildLeftAlignedBar(new JButton []{ 130 button1, button2, button3, button4, button5 131 }); 132 } 133 134 140 public static JPanel buildLeftAlignedBar(JButton [] buttons) { 141 ButtonBarBuilder builder = new ButtonBarBuilder(); 142 builder.addGriddedButtons(buttons); 143 builder.addGlue(); 144 return builder.getPanel(); 145 } 146 147 149 155 public static JPanel buildCenteredBar(JButton button1) { 156 return buildCenteredBar(new JButton []{ 157 button1 158 }); 159 } 160 161 168 public static JPanel buildCenteredBar( 169 JButton button1, JButton button2) { 170 return buildCenteredBar(new JButton []{ 171 button1, button2 172 }); 173 } 174 175 183 public static JPanel buildCenteredBar( 184 JButton button1, JButton button2, JButton button3) { 185 return buildCenteredBar(new JButton []{ 186 button1, button2, button3 187 }); 188 } 189 190 199 public static JPanel buildCenteredBar( 200 JButton button1, JButton button2, JButton button3, JButton button4) { 201 return buildCenteredBar(new JButton []{ 202 button1, button2, button3, button4 203 }); 204 } 205 206 216 public static JPanel buildCenteredBar( 217 JButton button1, JButton button2, JButton button3, 218 JButton button4, JButton button5) { 219 return buildCenteredBar(new JButton []{ 220 button1, button2, button3, button4, button5 221 }); 222 } 223 224 230 public static JPanel buildCenteredBar(JButton [] buttons) { 231 ButtonBarBuilder builder = new ButtonBarBuilder(); 232 builder.addGlue(); 233 builder.addGriddedButtons(buttons); 234 builder.addGlue(); 235 return builder.getPanel(); 236 } 237 238 239 245 public static JPanel buildGrowingBar(JButton button1) { 246 return buildGrowingBar(new JButton []{ 247 button1 248 }); 249 } 250 251 258 public static JPanel buildGrowingBar( 259 JButton button1, JButton button2) { 260 return buildGrowingBar(new JButton []{ 261 button1, button2 262 }); 263 } 264 265 273 public static JPanel buildGrowingBar( 274 JButton button1, JButton button2, JButton button3) { 275 return buildGrowingBar(new JButton []{ 276 button1, button2, button3 277 }); 278 } 279 280 289 public static JPanel buildGrowingBar( 290 JButton button1, JButton button2, JButton button3, JButton button4) { 291 return buildGrowingBar(new JButton []{ 292 button1, button2, button3, button4 293 }); 294 } 295 296 306 public static JPanel buildGrowingBar( 307 JButton button1, JButton button2, JButton button3, 308 JButton button4, JButton button5) { 309 return buildGrowingBar(new JButton []{ 310 button1, button2, button3, button4, button5 311 }); 312 } 313 314 321 public static JPanel buildGrowingBar(JButton [] buttons) { 322 ButtonBarBuilder builder = new ButtonBarBuilder(); 323 builder.addGriddedGrowingButtons(buttons); 324 return builder.getPanel(); 325 } 326 327 328 330 336 public static JPanel buildRightAlignedBar(JButton button1) { 337 return buildRightAlignedBar(new JButton []{ 338 button1 339 }); 340 } 341 342 349 public static JPanel buildRightAlignedBar( 350 JButton button1, JButton button2) { 351 return buildRightAlignedBar(new JButton []{ 352 button1, button2 353 }); 354 } 355 356 364 public static JPanel buildRightAlignedBar( 365 JButton button1, JButton button2, JButton button3) { 366 return buildRightAlignedBar(new JButton []{ 367 button1, button2, button3 368 }); 369 } 370 371 380 public static JPanel buildRightAlignedBar( 381 JButton button1, JButton button2, JButton button3, JButton button4) { 382 return buildRightAlignedBar(new JButton []{ 383 button1, button2, button3, button4 384 }); 385 } 386 387 397 public static JPanel buildRightAlignedBar( 398 JButton button1, JButton button2, JButton button3, 399 JButton button4, JButton button5) { 400 return buildRightAlignedBar(new JButton []{ 401 button1, button2, button3, button4, button5 402 }); 403 } 404 405 411 public static JPanel buildRightAlignedBar(JButton [] buttons) { 412 ButtonBarBuilder builder = new ButtonBarBuilder(); 413 builder.addGlue(); 414 builder.addGriddedButtons(buttons); 415 return builder.getPanel(); 416 } 417 418 419 421 428 public static JPanel buildHelpBar(JButton help, 429 JButton button1) { 430 return buildHelpBar(help, new JButton []{ 431 button1 432 }); 433 } 434 435 443 public static JPanel buildHelpBar(JButton help, 444 JButton button1, JButton button2) { 445 return buildHelpBar(help, new JButton []{ 446 button1, button2 447 }); 448 } 449 450 459 public static JPanel buildHelpBar(JButton help, 460 JButton button1, JButton button2, JButton button3) { 461 return buildHelpBar(help, new JButton []{ 462 button1, button2, button3 463 }); 464 } 465 466 476 public static JPanel buildHelpBar(JButton help, 477 JButton button1, JButton button2, JButton button3, JButton button4) { 478 return buildHelpBar(help, new JButton []{ 479 button1, button2, button3, button4 480 }); 481 } 482 483 490 public static JPanel buildHelpBar(JButton help, JButton [] buttons) { 491 ButtonBarBuilder builder = new ButtonBarBuilder(); 492 builder.addGridded(help); 493 builder.addRelatedGap(); 494 builder.addGlue(); 495 builder.addGriddedButtons(buttons); 496 return builder.getPanel(); 497 } 498 499 500 502 507 public static JPanel buildCloseBar(JButton close) { 508 return buildRightAlignedBar(close); 509 } 510 511 516 public static JPanel buildOKBar(JButton ok) { 517 return buildRightAlignedBar(ok); 518 } 519 520 526 public static JPanel buildOKCancelBar( 527 JButton ok, JButton cancel) { 528 return buildRightAlignedBar(ok, cancel); 529 } 530 531 538 public static JPanel buildOKCancelApplyBar( 539 JButton ok, JButton cancel, JButton apply) { 540 return buildRightAlignedBar(ok, cancel, apply); 541 } 542 543 545 552 public static JPanel buildHelpCloseBar( 553 JButton help, JButton close) { 554 return buildHelpBar(help, close); 555 } 556 557 564 public static JPanel buildHelpOKBar( 565 JButton help, JButton ok) { 566 return buildHelpBar(help, ok); 567 } 568 569 577 public static JPanel buildHelpOKCancelBar( 578 JButton help, JButton ok, JButton cancel) { 579 return buildHelpBar(help, ok, cancel); 580 } 581 582 591 public static JPanel buildHelpOKCancelApplyBar( 592 JButton help, JButton ok, JButton cancel, JButton apply) { 593 return buildHelpBar(help, ok, cancel, apply); 594 } 595 596 597 599 606 public static JPanel buildCloseHelpBar( 607 JButton close, JButton help) { 608 return buildRightAlignedBar(close, help); 609 } 610 611 618 public static JPanel buildOKHelpBar( 619 JButton ok, JButton help) { 620 return buildRightAlignedBar(ok, help); 621 } 622 623 631 public static JPanel buildOKCancelHelpBar( 632 JButton ok, JButton cancel, JButton help) { 633 return buildRightAlignedBar(ok, cancel, help); 634 } 635 636 645 public static JPanel buildOKCancelApplyHelpBar( 646 JButton ok, JButton cancel, JButton apply, JButton help) { 647 return buildRightAlignedBar(ok, cancel, apply, help); 648 } 649 650 651 653 660 public static JPanel buildAddRemoveLeftBar( 661 JButton add, JButton remove) { 662 return buildLeftAlignedBar(add, remove); 663 } 664 665 671 public static JPanel buildAddRemoveBar( 672 JButton add, JButton remove) { 673 return buildGrowingBar(add, remove); 674 } 675 676 683 public static JPanel buildAddRemoveRightBar( 684 JButton add, JButton remove) { 685 return buildRightAlignedBar(add, remove); 686 } 687 688 689 691 699 public static JPanel buildAddRemovePropertiesLeftBar( 700 JButton add, JButton remove, JButton properties) { 701 ButtonBarBuilder builder = new ButtonBarBuilder(); 702 builder.addGriddedButtons(new JButton []{ 703 add, remove, properties 704 }); 705 builder.addGlue(); 706 return builder.getPanel(); 707 } 708 709 717 public static JPanel buildAddRemovePropertiesBar( 718 JButton add, JButton remove, JButton properties) { 719 ButtonBarBuilder builder = new ButtonBarBuilder(); 720 builder.addGriddedGrowing(add); 721 builder.addRelatedGap(); 722 builder.addGriddedGrowing(remove); 723 builder.addRelatedGap(); 724 builder.addGriddedGrowingNarrow(properties); 725 return builder.getPanel(); 726 } 727 728 736 public static JPanel buildAddRemovePropertiesRightBar( 737 JButton add, JButton remove, JButton properties) { 738 ButtonBarBuilder builder = new ButtonBarBuilder(); 739 builder.addGlue(); 740 builder.addGriddedButtons(new JButton []{ 741 add, remove, properties 742 }); 743 return builder.getPanel(); 744 } 745 746 748 758 public static JPanel buildWizardBar( 759 JButton back, JButton next, JButton finish, JButton cancel) { 760 return buildWizardBar(back, next, new JButton []{finish, cancel}); 761 } 762 763 774 public static JPanel buildWizardBar( 775 JButton help, JButton back, JButton next, JButton finish, JButton cancel) { 776 return buildWizardBar(new JButton []{help}, 777 back, next, 778 new JButton []{finish, cancel}); 779 } 780 781 791 public static JPanel buildWizardBar(JButton back, JButton next, 792 JButton [] rightAlignedButtons) { 793 return buildWizardBar(null, back, next, rightAlignedButtons); 794 } 795 796 809 public static JPanel buildWizardBar(JButton [] leftAlignedButtons, 810 JButton back, JButton next, 811 JButton [] rightAlignedButtons) { 812 return buildWizardBar(leftAlignedButtons, 813 back, next, null, 814 rightAlignedButtons); 815 } 816 817 832 public static JPanel buildWizardBar(JButton [] leftAlignedButtons, 833 JButton back, 834 JButton next, 835 JButton overlayedFinish, 836 JButton [] rightAlignedButtons) { 837 838 ButtonBarBuilder builder = new ButtonBarBuilder(); 839 if (leftAlignedButtons != null) { 840 builder.addGriddedButtons(leftAlignedButtons); 841 builder.addRelatedGap(); 842 } 843 builder.addGlue(); 844 builder.addGridded(back); 845 builder.addGridded(next); 846 847 if (overlayedFinish != null) { 849 builder.nextColumn(-1); 850 builder.add(overlayedFinish); 851 builder.nextColumn(); 852 } 853 854 if (rightAlignedButtons != null) { 855 builder.addRelatedGap(); 856 builder.addGriddedButtons(rightAlignedButtons); 857 } 858 return builder.getPanel(); 859 } 860 861 862 } | Popular Tags |