How to redirect input/output/error from Process Builder To TextArea

Navdeep Singh Sidhu navdeepsingh.sidhu95 at gmail.com
Wed Jan 21 15:31:24 UTC 2015


I am experimenting with JavaFX and tried to build a Console/Command Prompt
. But i don't know how to redirect Input/Output/Error From ProcessBuilder
to TextArea.


public class JavaFXConsole extends Application {

    @Override
    public void start(Stage primaryStage) {
        TextArea ta = new TextArea();
        ta.onKeyTypedProperty().addListener(new
ChangeListener<EventHandler<? super KeyEvent>>() {

            @Override
            public void changed(ObservableValue<? extends EventHandler<?
super KeyEvent>> observable, EventHandler<? super KeyEvent> oldValue,
EventHandler<? super KeyEvent> newValue) {

            }
        });
        HBox root = new HBox();
        root.getChildren().add(ta);
        ProcessBuilder pb = new ProcessBuilder("bash");
        pb.inheritIO();
        try {
            pb.start();
        } catch (IOException ex) {

Logger.getLogger(JavaFXConsole.class.getName()).log(Level.SEVERE, null, ex);
        }

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

Thanks in advance !!
-- 
Regards
Navdeep Singh Sidhu


More information about the openjfx-dev mailing list