I have created a console Application and now starting it to convert into swing Application. I have one question and I search many times for you answer but I dont find any.
My application has an class wich validate the input of the User and also if the input is wrong it gives a error msg into console. So what I try to do is, I have an Jtextfield and validate this input, if the input is wrong it should give me the error msg.
Thats my Input class where the User is alowed to write
public class Input {
private static BufferedReader eingabe = new BufferedReader(new InputStreamReader(System.in));
private Output output = new Output();
private static String captureText() throws Exception {
return eingabe.readLine();
}
public String formatInput() {
boolean again = true;
while (again) {
try {
String format = captureText();
if (!format.equalsIgnoreCase("Y") && !format.equalsIgnoreCase("N")) {
again = true;
throw new Exception();
}
again = false;
return format;
} catch (Exception e) {
this.output.formatInputWrong();
}
}
return null;
}
}
Thats my output class method
void formatInputWrong() {
System.out.print("\nThe Format Input is wrong.");
}
I just wanna know can I use the Validation of the Input class or should I create a special class for the swing input validation because I know I can take out the Input of the JTextfield