-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueInputVerifier.java
More file actions
43 lines (34 loc) · 1.08 KB
/
ValueInputVerifier.java
File metadata and controls
43 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* ValueInputVerifier.java
*
* See EcgLicense.txt for License terms.
*/
/**
*
* @author Mauricio Villarroel (m.villarroel@acm.og)
*/
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.JComponent;
public class ValueInputVerifier {
/** Creates a new instance of ValueInputVerifier */
public ValueInputVerifier() {
}
public static boolean verify(JComponent input, EcgString str, String verifyType) {
JTextField textF = (JTextField) input;
boolean RetValue = true;
try {
if(verifyType == "Integer"){
int dNumber;
dNumber = Integer.valueOf(textF.getText()).intValue();
} else if(verifyType == "Double"){
double dNumber;
dNumber = Double.valueOf(textF.getText()).doubleValue();
}
} catch(java.lang.NumberFormatException e){
str.setString("You have to enter a(n) " + verifyType + " number, please retry!!!");
RetValue = false;
}
return(RetValue);
}
}