can you help me with input mask?
String format = "X-XX-XXX"
X is the user input from console / keyboard.
I keep wanting to show the dash (-) while the user input to the string format.
Can you help me to solve my problem?
can you help me with input mask?
String format = "X-XX-XXX"
X is the user input from console / keyboard.
I keep wanting to show the dash (-) while the user input to the string format.
Can you help me to solve my problem?
It's impossible to show the entire mask while typing, but what you can do is read individual chars in at a time and when you get to the relevant places, output a dash.
Edit: It may be possible to move the cursor in the console, that way you can output the mask and then manoeuvre the cursor accordingly (depending on how many keys have been pressed).
I just found this here:
char escCode = 0x1B;
int row = 10; int column = 10;
System.out.print(String.format("%c[%d;%df",escCode,row,column));
Which should move the cursor to position 10,10 on the console.
Unfortunately, there is no unbuffered console I/O for java. You have to bind curses via JNI probably:
http://plindenbaum.blogspot.com/2008/01/java-native-interface-jni-notebook.html