1 19 20 package de.gulden.util.swing; 21 22 import java.util.*; 23 import javax.swing.InputVerifier ; 24 import javax.swing.JComponent ; 25 26 32 public class InputVerifierNumber extends InputVerifier { 33 34 38 41 protected Class type; 42 43 44 48 51 public InputVerifierNumber() { 52 this(Integer .class); 53 } 54 55 58 public InputVerifierNumber(Class type) { 59 super(); 60 setType(type); 61 } 62 63 64 68 public boolean verify(JComponent input) { 69 javax.swing.text.JTextComponent textComponent=(javax.swing.text.JTextComponent )input; 71 Number number=(Number )de.gulden.util.Toolbox.invokeValueOf(type,textComponent.getText()); 72 return (number!=null); 73 } 74 75 78 public Class getType() { 79 return type; 80 } 81 82 85 public void setType(Class _type) { 86 type = _type; 87 } 88 89 } | Popular Tags |