I am trying to make a simple replicate of a terminal for a swing application. I want to run a java class, and any of its errors or output to be displayed on a JTextPane. The part where I am stuck is getting input from a JTextField , on a way similar to terminal( type the command/ input hit enter ). What I want is when pressing enter, my input is send to the process being executed. I have tried overriding InputStream methods but it hasn't worked yet.
This is the class I want to control through my terminal . public class NewClass { BufferedReader in ; public NewClass(){ in = new BufferedReader(new InputStreamReader(System.in)); run(); } private void run(){ while (true){ System.out.println("Who are you ?"); try { System.out.println("Hello "+in.readLine()); } catch (IOException ex) { Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex); } } } public static void main(String[] args) { new NewClass(); } } And this is how I set my custom output Executor ex = new DefaultExecutor(); ex.setStreamHandler(new PumpStreamHandler(out, outerr, in)); --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org