gravsphcolldemo
Class Vector3DInputVerifier

java.lang.Object
  |
  +--javax.swing.InputVerifier
        |
        +--gravsphcolldemo.Vector3DInputVerifier

public class Vector3DInputVerifier
extends javax.swing.InputVerifier

This is a subclass of InputVerifier that can be used to validate a JTextField. The contents are valid if the text can be interpreted as a Vector3D (using the Vector3D constructor taking a String).

Version:
1.0
Author:
Miklos Reiter

Constructor Summary
Vector3DInputVerifier()
          Constructs a new Vector3DInputVerifier object.
Vector3DInputVerifier(boolean emptyEntryAccepted)
          Constructs a new Vector3DInputVerifier object.
 
Method Summary
 boolean getAcceptEmpty()
          Is the empty string accepted as a valid entry?
 void setAcceptEmpty(boolean emptyEntryAccepted)
          Sets whether the empty string should be accepted as valid.
 boolean shouldYieldFocus(javax.swing.JComponent input)
          Displays a message box complaining to the user and informing them briefly of the format of a Vector3D, if the input is invalid, in addition to calling the inherited method.
static boolean validVector3D(java.lang.String s)
          Returns true if the argument represents a valid Vector3D.
 boolean verify(javax.swing.JComponent input)
          Casts the argument as a JTextField, then parses it as a Vector3D.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vector3DInputVerifier

public Vector3DInputVerifier()
Constructs a new Vector3DInputVerifier object. This verifier will accept the empty string as a valid entry.

Vector3DInputVerifier

public Vector3DInputVerifier(boolean emptyEntryAccepted)
Constructs a new Vector3DInputVerifier object.
Method Detail

getAcceptEmpty

public boolean getAcceptEmpty()
Is the empty string accepted as a valid entry?

setAcceptEmpty

public void setAcceptEmpty(boolean emptyEntryAccepted)
Sets whether the empty string should be accepted as valid.

shouldYieldFocus

public boolean shouldYieldFocus(javax.swing.JComponent input)
Displays a message box complaining to the user and informing them briefly of the format of a Vector3D, if the input is invalid, in addition to calling the inherited method.
Overrides:
shouldYieldFocus in class javax.swing.InputVerifier

verify

public boolean verify(javax.swing.JComponent input)
Casts the argument as a JTextField, then parses it as a Vector3D. Returns true if it succeeds, false otherwise. Calls validVector3D to do this. True is also returned if s is the empty String and getAcceptEmpty is true.
Overrides:
verify in class javax.swing.InputVerifier

validVector3D

public static boolean validVector3D(java.lang.String s)
Returns true if the argument represents a valid Vector3D. Uses the constructor of the Vector3D class taking a String.