redirect inputStream to JTextField
- by gt_ebuddy
I want to redirect the Standard System input to JTextField,
So that a user must type his/her input in JTextField (instead of console.)
I found System.setIn(InputStream istream) for redirecting System.in.
Here is my scratch code where i confused on reading from JTextField - inputJTextField.
System.setIn(new InputStream() {
@Override
public int read() throws IOException {
//how to read content?
return Integer.parseInt(inputJTextField.getText());
}
});
My Question is how to read content from GUI Component ( like JTextField and Cast it to String and other types after redirecting the input stream?