1 19 20 package org.netbeans.modules.form.beaninfo.awt; 21 22 import java.awt.Label ; 23 import java.beans.*; 24 25 import org.openide.util.NbBundle; 26 27 32 public class LabelBeanInfo extends ComponentBeanInfo.Support { 33 34 public LabelBeanInfo() { 35 super("label", java.awt.Label .class); } 37 38 39 protected PropertyDescriptor[] createPDs() throws IntrospectionException { 40 PropertyDescriptor[] pds = new PropertyDescriptor[] { 41 new PropertyDescriptor("alignment", Label .class), new PropertyDescriptor("text", Label .class), }; 44 pds[0].setPropertyEditorClass(LabelBeanInfo.AlignmentPropertyEditor.class); 45 return pds; 46 } 47 48 public static class AlignmentPropertyEditor extends PropertyEditorSupport { 49 String [] tags; 50 51 52 public synchronized String [] getTags() { 53 if (tags == null) { 54 tags = new String [] { 55 getString("LEFT"), 56 getString("CENTER"), 57 getString("RIGHT") 58 }; 59 } 60 return tags; 61 } 62 63 public void setAsText(String s) { 64 Integer i; 65 getTags(); 66 if (s.equals(tags[0])) i = new Integer (java.awt.Label.LEFT); 67 else if (s.equals(tags[1])) i = new Integer (java.awt.Label.CENTER); 68 else i = new Integer (java.awt.Label.RIGHT); 69 setValue(i); 70 } 71 72 public String getAsText() { 73 int i = ((Integer ) getValue()).intValue(); 74 getTags(); 75 return tags[i == java.awt.Label.CENTER ? 1 : (i == java.awt.Label.LEFT ? 0 : 2)]; 76 } 77 78 public String getJavaInitializationString () { 79 int i = ((Integer ) getValue()).intValue(); 80 switch (i) { 81 case java.awt.Label.RIGHT : return "java.awt.Label.RIGHT"; case java.awt.Label.LEFT : return "java.awt.Label.LEFT"; default: 84 case java.awt.Label.CENTER : return "java.awt.Label.CENTER"; } 86 } 87 } 88 89 90 static String getString(String x) { 91 return NbBundle.getMessage(LabelBeanInfo.class, x); 92 } 93 } 94 | Popular Tags |