JavaDoc


001    /**
002     * Copyright (c) 2003 Daffodil Software Ltd all rights reserved,
003     * Modifications Copyright (c) 2008 Regiscope Digital Imaging Co, LLC, All rights reserved.
004     * This program is free software; you can redistribute it and/or modify
005     * it under the terms of version 2 of the GNU General Public License as
006     * published by the Free Software Foundation.
007     * There are special exceptions to the terms and conditions of the GPL
008     * as it is applied to this software. See the GNU General Public License for more details.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018     */
019    
020    package org.dbreplicator.repconsole;
021    
022    import javax.swing.text.*;
023    
024    public class NumericDocument extends PlainDocument
025    {
026    
027        public void insertString(int off, String str, AttributeSet attr)
028        {
029            try
030            {
031                char strChar = str.charAt(0);
032                String txt = getText(0, getLength());
033                if ( (strChar >= '0' && strChar <= '9') ||
034                    ( (strChar == 'I') &&
035                     ( (str.equals("Infinity")) || (str.equals("Invalid Input")))))
036                {
037                    if (str.equals(".") && txt.indexOf(".") >= 0)
038                    {
039                        return;
040                    }
041                    super.insertString(off, str, attr);
042                }
043                else
044                {
045                    return;
046                }
047            }
048            catch (Exception e)
049            {}
050        }
051    
052        public void remove(int off, int len)
053        {
054            try
055            {
056                super.remove(off, len);
057                String str = getText(0, getLength());
058            }
059            catch (Exception e)
060            {}
061        }
062    }





























































Powered by Drupal - Theme by Danger4k