Input Validation - Jtext Field in Java (Java 2 SE)
$30-250 USD
Cancelado
Publicado há quase 11 anos
$30-250 USD
Pago na entrega
I have already a Java application that takes input of students and stores in a .dat file (in rows and columns). The problem that I am facing right now is that in one of the class files (which is used to enter student details), I have a JTextField element that takes the marks of the students. I want only a certain range of number to be entered in the this field, say between 20 and 30 or between 40 and 60 like that....
Currently I am using to implement this input validation using a key event listener but it is not working properly and giving an error : 'invalid character constant' in eclipse IDE. I don't want to use anything else than this key event listener method as it will mess up the whole code. This is the current piece of code that is giving me trouble. If you think you can implement this without affecting or changing the main program, pls PM me with rates.
// input validation that restricts user to enter specific number range
between 20 and 30
[login to view URL](new KeyAdapter() {
public void keyTyped(KeyEvent ke) {
char c = [login to view URL]();
if(!([login to view URL]() >= '20' && [login to view URL]() <= '30')) {
getToolkit().beep();
[login to view URL]();
}
}
});