Hi All
I am trying to change my System.in InputStream to instead take values from the terminal window but take values from a JEditorPane or JTextBox.
I have this to add the text to the new InputStream which has been declared.
I then want to use this in another class to output the text:
But I get java.lang.NullP ointerException at java.io.Reader. (Unknown Source) at java.io.InputSt reamReader. (Unknown Source).
What I have is a CLI applciation that runs off the User inputs from the terminal within Eclipse all I want to do is change main System.in input Stream to a Jtextbox output. I have the above working just in CLI (of course not setting System.setIn(). ..)
Any pointers would be awsome!
I am trying to change my System.in InputStream to instead take values from the terminal window but take values from a JEditorPane or JTextBox.
I have this to add the text to the new InputStream which has been declared.
Code:
GUI Class:
public static InputStream consoleInputStream;
...
sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message = sendPane.getText();
consoleInputStream = new ByteArrayInputStream(message.getBytes());
sendPane.setText("");
}
});
Code:
System.setIn(GUI.consoleInputStream);
...
public static String readLine() {
String s = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
s = in.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return s;
}
What I have is a CLI applciation that runs off the User inputs from the terminal within Eclipse all I want to do is change main System.in input Stream to a Jtextbox output. I have the above working just in CLI (of course not setting System.setIn(). ..)
Any pointers would be awsome!