/*
* Project: Gulden Utilies
* Class: de.gulden.util.swing.InputVerifierNumber
* Version: snapshot-beautyj-1.1
*
* Date: 2004-09-29
*
* This is a snapshot version of the Gulden Utilities,
* it is not released as a seperate version.
*
* Note: Contains auto-generated Javadoc comments created by BeautyJ.
*
* This is licensed under the GNU Lesser General Public License (LGPL)
* and comes with NO WARRANTY.
*
* Author: Jens Gulden
* Email: amoda@jensgulden.de
*/
package de.gulden.util.swing;
import java.util.*;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
/**
* Class InputVerifierNumber.
*
* @author Jens Gulden
* @version snapshot-beautyj-1.1
*/
public class InputVerifierNumber extends InputVerifier {
// ------------------------------------------------------------------------
// --- field ---
// ------------------------------------------------------------------------
/**
* The type.
*/
protected Class type;
// ------------------------------------------------------------------------
// --- constructors ---
// ------------------------------------------------------------------------
/**
* Creates a new instance of InputVerifierNumber.
*/
public InputVerifierNumber() {
this(Integer.class);
}
/**
* Creates a new instance of InputVerifierNumber.
*/
public InputVerifierNumber(Class type) {
super();
setType(type);
}
// ------------------------------------------------------------------------
// --- methods ---
// ------------------------------------------------------------------------
public boolean verify(JComponent input) {
// can only verify JTextComponent
javax.swing.text.JTextComponent textComponent=(javax.swing.text.JTextComponent)input;
Number number=(Number)de.gulden.util.Toolbox.invokeValueOf(type,textComponent.getText());
return (number!=null);
}
/**
* Returns the type.
*/
public Class getType() {
return type;
}
/**
* Sets the type.
*/
public void setType(Class _type) {
type = _type;
}
} // end InputVerifierNumber
|