1 30 31 package com.jgoodies.forms.extras; 32 33 import java.util.MissingResourceException ; 34 import java.util.ResourceBundle ; 35 36 import javax.swing.JComponent ; 37 import javax.swing.JLabel ; 38 import javax.swing.JPanel ; 39 40 import com.jgoodies.forms.builder.PanelBuilder; 41 import com.jgoodies.forms.layout.CellConstraints; 42 import com.jgoodies.forms.layout.FormLayout; 43 44 60 public class I15dPanelBuilder extends PanelBuilder { 61 62 66 private final ResourceBundle bundle; 67 68 69 71 80 public I15dPanelBuilder(JPanel panel, FormLayout layout, ResourceBundle bundle){ 81 super(panel, layout); 82 this.bundle = bundle; 83 } 84 85 92 public I15dPanelBuilder(FormLayout layout, ResourceBundle bundle){ 93 this(new JPanel (), layout, bundle); 94 } 95 96 97 99 107 public final JLabel addI15dLabel(String resourceKey, CellConstraints constraints) { 108 return addLabel(getI15dString(resourceKey), constraints); 109 } 110 111 119 public final JLabel addI15dLabel(String resourceKey, String encodedConstraints) { 120 return addI15dLabel(resourceKey, new CellConstraints(encodedConstraints)); 121 } 122 123 131 public final JComponent addI15dSeparator(String resourceKey, CellConstraints constraints) { 132 return addSeparator(getI15dString(resourceKey), constraints); 133 } 134 135 143 public final JComponent addI15dSeparator(String resourceKey, String encodedConstraints) { 144 return addI15dSeparator(resourceKey, new CellConstraints(encodedConstraints)); 145 } 146 147 154 public final JLabel addI15dTitle(String resourceKey, CellConstraints constraints) { 155 return addTitle(getI15dString(resourceKey), constraints); 156 } 157 158 165 public final JLabel add15dTitle(String resourceKey, String encodedConstraints) { 166 return addI15dTitle(resourceKey, new CellConstraints(encodedConstraints)); 167 } 168 169 170 172 182 protected String getI15dString(String resourceKey) { 183 if (bundle == null) 184 throw new IllegalStateException ("You must specify a ResourceBundle" + 185 " before using the internationalization support."); 186 try { 187 return bundle.getString(resourceKey); 188 } catch (MissingResourceException mre) { 189 return resourceKey; 190 } 191 } 192 193 194 195 } 196 | Popular Tags |