Java Code Examples for java.awt.TextField#getText()

The following examples show how to use java.awt.TextField#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CpnZoomScreen.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static boolean intFieldError( 
                    TextField theField,
                    double minValue,
                    double maxValue ) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    if (!fieldTokenizer.hasMoreElements()) {
        theField.setText("Error");
        return true;
    }                    
    else {
        String fieldString = 
                fieldTokenizer.nextToken();             
        try {
            int fieldValue = 
                new Integer(fieldString)
                    .intValue();  
            if (fieldValue < minValue ) {
                theField.setText("Error");
                return true;
            }                                                          
            else if (fieldValue > maxValue ) {
                theField.setText("Error");
                return true;
            }                                                          
        }                            
        catch (Throwable e ) {
            theField.setText("Error");
            return true;
        }                            
    }            
    if (fieldTokenizer.hasMoreElements()) {
        theField.setText("Error");
        return true;
    }   
    else {
        return false;                
    }            
}
 
Example 2
Source File: CpnZoomScreen.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static int getIntegerValue( 
                    TextField theField ) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    String fieldString = 
               fieldTokenizer.nextToken();             
    return new Integer(fieldString).intValue();  
}
 
Example 3
Source File: NoteEditor.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static boolean validateFloatEdit(
            TextField   theField,
            double      minValue,
            double      maxValue) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    if (!fieldTokenizer.hasMoreElements()) {
        theField.setText("Error--No Data");
        return false;
    }                    
    else {
        String fieldString = 
                fieldTokenizer.nextToken();             
        try {
            double fieldValue = 
                new Double(fieldString)
                    .doubleValue();  
            if (fieldValue < minValue ) {
                theField.setText("Value Too Low");
                return false;
            }                                                          
            else if (fieldValue < minValue ) {
                theField.setText("Value Too High");
                return false;
            }                                                          
        }                            
        catch (Throwable e ) {
            theField.setText("Data Error");
            return false;
        }                            
    }            
    if (fieldTokenizer.hasMoreElements()) {
        theField.setText("Data Error");
        return false;
    }   
    else {
        return true;                
    }                             
}
 
Example 4
Source File: NoteEditor.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static double getFieldDouble(
            TextField   theField
        ) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    String fieldString = 
                fieldTokenizer.nextToken();             
    return (new Double(fieldString)).doubleValue();  
}
 
Example 5
Source File: NoteEditor.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static boolean validateIntegerEdit(
            TextField   theField,
            int         minValue,
            int         maxValue) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    if (!fieldTokenizer.hasMoreElements()) {
        theField.setText("Error--No Data");
        return false;
    }                    
    else {
        String fieldString = 
                fieldTokenizer.nextToken();             
        try {
            int fieldValue = 
                new Integer(fieldString)
                    .intValue();  
            if (fieldValue < minValue ) {
                theField.setText("Value Too Low");
                return false;
            }                                                          
            else if (fieldValue > maxValue ) {
                theField.setText("Value Too High");
                return false;
            }                                                          
        }                            
        catch (Throwable e ) {
            theField.setText("Data Error");
            return false;
        }                            
    }            
    if (fieldTokenizer.hasMoreElements()) {
        theField.setText("Data Error");
        return false;
    }   
    else {
        return true;                
    }                             
}
 
Example 6
Source File: NoteEditor.java    From jmg with GNU General Public License v2.0 5 votes vote down vote up
private static int getFieldInt(
            TextField   theField
        ) {
    StringTokenizer fieldTokenizer                    
        = new StringTokenizer(theField.getText());
    String fieldString = 
                fieldTokenizer.nextToken();             
    return (new Integer(fieldString)).intValue();  
}