1 19 20 package org.netbeans.beaninfo.editors; 21 22 import java.awt.Dimension ; 23 import org.netbeans.core.UIExceptions; 24 import org.openide.explorer.propertysheet.ExPropertyEditor; 25 import org.openide.util.NbBundle; 26 27 31 public class DimensionEditor extends ArrayOfIntSupport { 32 public DimensionEditor() { 33 super("java.awt.Dimension", 2); } 35 36 37 int[] getValues() { 38 Dimension d = (Dimension ) getValue(); 39 return new int[] { d.width, d.height }; 40 } 41 42 static String toArr (int[] ints) { 43 StringBuffer sb = new StringBuffer (); 44 if ((ints != null) && (ints.length > 0)) { 45 for (int i=0; i < ints.length; i++) { 46 sb.append (ints[i]); 47 if (i != ints.length-1) { 48 sb.append (','); } 50 } 51 } else { 52 return NbBundle.getMessage (DimensionEditor.class, 53 "MSG_NULL_OR_EMPTY"); } 55 return sb.toString(); 56 } 57 58 61 void setValues(int[] val) { 62 if ((val[0] < 0) || (val[1] < 0)) { 63 String msg = NbBundle.getMessage(DimensionEditor.class, 64 "CTL_NegativeSize"); IllegalArgumentException iae = new IllegalArgumentException ( 66 "Negative value"); UIExceptions.annotateUser(iae, iae.getMessage(), msg, null, 68 new java.util.Date ()); 69 throw iae; 70 } 71 else 72 setValue(new Dimension (val[0], val[1])); 73 } 74 75 public boolean supportsCustomEditor () { 76 return true; 77 } 78 79 public java.awt.Component getCustomEditor () { 80 return new PointCustomEditor (this, env); 81 } 82 83 84 85 String getHintFormat() { 86 return NbBundle.getMessage(DimensionEditor.class, "CTL_HintFormat"); } 88 89 90 protected String getXMLValueTag () { 91 return "Dimension"; } 93 94 } 95 | Popular Tags |