1 19 20 package org.netbeans.beaninfo.editors; 21 22 import java.awt.Rectangle ; 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 RectangleEditor extends ArrayOfIntSupport { 32 33 public RectangleEditor() { 34 super("java.awt.Rectangle", 4); } 36 37 38 int[] getValues() { 39 Rectangle rect = (Rectangle ) getValue(); 40 return new int[] { rect.x, rect.y, rect.width, rect.height }; 41 } 42 43 46 void setValues(int[] val) { 47 if ((val[0] < 0) || (val[1] < 0) || (val[2] < 0) || (val[3] < 0)) { 48 String msg = NbBundle.getMessage(DimensionEditor.class, 49 "CTL_NegativeSize"); IllegalArgumentException iae = new IllegalArgumentException ( 51 "Negative value"); UIExceptions.annotateUser(iae, iae.getMessage(), msg, null, 53 new java.util.Date ()); 54 throw iae; 55 56 } 57 else 58 setValue(new Rectangle (val[0], val[1], val[2], val[3])); 59 } 60 61 public boolean supportsCustomEditor () { 62 return true; 63 } 64 65 public java.awt.Component getCustomEditor () { 66 return new RectangleCustomEditor (this, env); 67 } 68 69 70 String getHintFormat() { 71 return NbBundle.getMessage(RectangleEditor.class, "CTL_HintFormatRE"); 72 } 73 74 75 protected String getXMLValueTag () { 76 return "Rectangle"; } 78 79 private PropertyEnv env; 80 public void attachEnv(PropertyEnv env) { 81 this.env = env; 83 } 84 85 } 86 | Popular Tags |