Using the JavaFX Component

Lee Painter

Setting up

You will first need to import the terminal-javafx module in your maven project.


Creating the Terminal Display

The structure of a JavaFX application is slightly different. For standalone applications, you generally extend Application and override the start(Stage) method. If you already have a component you wish to embed a terminal into, use a reference to that instead:

public void start(Stage primaryStage) {
    // insert code here ...

Create the JavaFX terminal component:

JavaFXTerminalPanel display = new JavaFXTerminalPanel();

You will need to put the component in some kind of container before adding to the scene:

BorderPane displayContainer = new BorderPane();

Now set the scene of the stage using the display container:

primaryStage.setScene(new Scene(displayContainer));;

You will next need to obtain a reference to the terminal and connect the terminal to a remote host. Return to the article Integrating a Terminal Into Your Application to complete this.