1 19 20 package org.netbeans.beaninfo.editors; 21 22 import java.awt.Insets ; 23 import org.netbeans.core.UIExceptions; 24 import org.openide.explorer.propertysheet.ExPropertyEditor; 25 import org.openide.explorer.propertysheet.PropertyEnv; 26 import org.openide.util.NbBundle; 27 28 31 public class InsetsEditor extends ArrayOfIntSupport { 32 public InsetsEditor() { 33 super("java.awt.Insets", 4); } 35 36 37 int[] getValues() { 38 Insets insets = (Insets ) getValue(); 39 if (insets != null) { 40 return new int[] { insets.top, insets.left, insets.bottom, insets.right }; 41 } else { 42 return new int[4]; 43 } 44 } 45 46 49 void setValues(int[] val) { 50 if ((val[0] < 0) || (val[1] < 0) || (val[2] < 0) || (val[3] < 0)) { 51 String msg = NbBundle.getMessage(DimensionEditor.class, 52 "CTL_NegativeSize"); IllegalArgumentException iae = new IllegalArgumentException ( 54 "Negative value"); UIExceptions.annotateUser(iae, iae.getMessage(), msg, null, 56 new java.util.Date ()); 57 throw iae; 58 59 } 60 else 61 setValue(new Insets (val[0], val[1], val[2], val[3])); 62 } 63 64 public boolean supportsCustomEditor () { 65 return true; 66 } 67 68 public java.awt.Component getCustomEditor () { 69 return new InsetsCustomEditor (this, env); 70 } 71 72 73 String getHintFormat() { 74 return NbBundle.getMessage (InsetsEditor.class, "CTL_HintFormatIE"); } 76 77 78 protected String getXMLValueTag () { 79 return "Insets"; } 81 82 private PropertyEnv env; 83 public void attachEnv(PropertyEnv env) { 84 this.env = env; 86 } 87 88 } 89 | Popular Tags |