add another java client
[spider.git] / spider-web / IntTextField.java
diff --git a/spider-web/IntTextField.java b/spider-web/IntTextField.java
new file mode 100755 (executable)
index 0000000..421a28f
--- /dev/null
@@ -0,0 +1,36 @@
+import java.awt.*;
+
+public class IntTextField extends TextField
+{
+
+       public IntTextField()
+       {
+               ;
+       }
+       
+       public IntTextField(String s) 
+       {
+               this.setText(s);
+       }
+       
+       public boolean isValid()
+       {
+               int value;
+               try
+               {
+                       value = Integer.valueOf(getText().trim()).intValue();
+
+               }
+               catch (NumberFormatException e)
+               {
+                       requestFocus();
+                       return false;
+               }
+               return true;
+       }
+       
+       public int getValue()
+       {
+               return Integer.parseInt(getText().trim(),10);
+       }
+}