1 21 22 package com.izforge.izpack.gui; 23 24 import javax.swing.Icon ; 25 import javax.swing.JLabel ; 26 import javax.swing.SwingConstants ; 27 28 36 public class LabelFactory implements SwingConstants 37 { 38 39 private static boolean useLabelIcons = true; 40 41 46 public static boolean isUseLabelIcons() 47 { 48 return useLabelIcons; 49 } 50 51 56 public static void setUseLabelIcons(boolean b) 57 { 58 useLabelIcons = b; 59 } 60 61 68 public static JLabel create(Icon image) 69 { 70 return (create(image, CENTER)); 71 72 } 73 74 82 public static JLabel create(Icon image, int horizontalAlignment) 83 { 84 return (create(null, image, horizontalAlignment)); 85 86 } 87 88 94 public static JLabel create(String text) 95 { 96 return (create(text, CENTER)); 97 98 } 99 100 107 public static JLabel create(String text, boolean isFullLine) 108 { 109 return (create(text, CENTER, isFullLine)); 110 111 } 112 113 120 public static JLabel create(String text, int horizontalAlignment) 121 { 122 return (create(text, null, horizontalAlignment)); 123 124 } 125 126 134 public static JLabel create(String text, int horizontalAlignment, boolean isFullLine) 135 { 136 return (create(text, null, horizontalAlignment, isFullLine)); 137 138 } 139 140 150 public static JLabel create(String text, Icon image, int horizontalAlignment) 151 { 152 return( create(text, image, horizontalAlignment, false)); 153 } 154 155 166 public static JLabel create(String text, Icon image, int horizontalAlignment, boolean isFullLine) 167 { 168 JLabel retval = null; 169 if (image != null && isUseLabelIcons()) 170 { 171 if (isFullLine) 172 retval = new FullLineLabel(image); 173 else 174 retval = new JLabel (image); 175 } 176 else 177 { 178 if (isFullLine) 179 retval = new FullLineLabel(); 180 else 181 retval = new JLabel (); 182 } 183 if (text != null) retval.setText(text); 184 retval.setHorizontalAlignment(horizontalAlignment); 185 return (retval); 186 } 187 188 198 public static class FullLineLabel extends JLabel 199 { 200 201 208 public FullLineLabel(Icon image) 209 { 210 super(image); 211 } 212 213 216 public FullLineLabel() 217 { 218 super(); 219 } 220 } 221 222 } 223 | Popular Tags |