All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.nih.nlm.nls.lvg.Tools.GuiTool.GuiLib.IntTextField Maven / Gradle / Ivy

The newest version!
package GuiTool.GuiLib;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
public class IntTextField extends JTextField
{
    public IntTextField(int defval, int size)
    {
        super("" + defval, size);
    }
    protected Document createDefaultModel()
    {
        return new IntTextDocument();
    }
    public boolean isValid()
    {
        try
        {
            Integer.parseInt(getText());
            return true;
        }
        catch(NumberFormatException e)
        {
            return false;
        }
    }
    public int getValue()
    {
        try
        {
            return Integer.parseInt(getText());
        }
        catch(NumberFormatException e)
        {
            return 0;
        }
    }
    private final static long serialVersionUID = 5L;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy