1 21 22 package com.izforge.izpack.gui; 23 24 import java.awt.Color ; 25 26 import javax.swing.Action ; 27 import javax.swing.Icon ; 28 import javax.swing.JButton ; 29 30 33 public class ButtonFactory 34 { 35 36 private static boolean useHighlightButtons = false; 37 38 private static boolean useButtonIcons = false; 39 40 43 public static void useButtonIcons() 44 { 45 useButtonIcons(true); 46 } 47 48 53 public static void useButtonIcons(boolean useit) 54 { 55 if (System.getProperty("mrj.version") == null) 56 { 57 useButtonIcons = useit; 58 } 59 } 60 61 64 public static void useHighlightButtons() 65 { 66 useHighlightButtons(true); 67 } 68 69 74 public static void useHighlightButtons(boolean useit) 75 { 76 if (System.getProperty("mrj.version") == null) 77 { 78 useHighlightButtons = useit; 79 } 80 useButtonIcons(useit); 81 } 82 83 public static JButton createButton(Icon icon, Color color) 84 { 85 if (useHighlightButtons) 86 { 87 if (useButtonIcons) 88 return new HighlightJButton(icon, color); 89 else 90 return new HighlightJButton("", color); 91 92 } 93 else 94 { 95 if (useButtonIcons) 96 { 97 return new JButton (icon); 98 } 99 else 100 { 101 return new JButton (); 102 } 103 } 104 } 105 106 public static JButton createButton(String text, Color color) 107 { 108 if (useHighlightButtons) 109 { 110 return new HighlightJButton(text, color); 111 } 112 else 113 { 114 return new JButton (text); 115 } 116 } 117 118 public static JButton createButton(String text, Icon icon, Color color) 119 { 120 if (useHighlightButtons) 121 { 122 if (useButtonIcons) 123 return new HighlightJButton(text, icon, color); 124 else 125 return new HighlightJButton(text, color); 126 } 127 else 128 { 129 if (useButtonIcons) 130 { 131 return new JButton (text, icon); 132 } 133 else 134 { 135 return new JButton (text); 136 } 137 } 138 } 139 140 public static JButton createButton(Action a, Color color) 141 { 142 if (useHighlightButtons) 143 { 144 return new HighlightJButton(a, color); 145 } 146 else 147 { 148 return new JButton (a); 149 } 150 } 151 152 } 153 | Popular Tags |