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

gov.nih.nlm.nls.lvg.Tools.GuiTool.GuiLib.IntTextDocument 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 IntTextDocument extends PlainDocument
{
    public void insertString(int offs, String str, AttributeSet a)
        throws BadLocationException
    {
        if(str == null)
        {
            return;
        }
        String oldString = getText(0, getLength());
        String newString = oldString.substring(0, offs) + str
            + oldString.substring(offs);
        try
        {
            Integer.parseInt(newString + "0");
            super.insertString(offs, str, a);
        }
        catch(NumberFormatException e)
        {
        }
    }
    private final static long serialVersionUID = 5L;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy