---
name: johannesrabauer/javafx-terminal-emulators
source: https://app.decimal.ai/s/johannesrabauer-javafx-terminal-emulators@1/SKILL.md
source_sha256: 6ea254c4c2fb
---

# JavaFX Terminal Emulators

Use this skill when the UI needs a real terminal emulator or a shell-like console pane for running
commands, inspecting logs, or talking to remote systems interactively.

## Example

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import javafx.application.Platform;
import javafx.scene.control.TextArea;

public class ConsolePane extends TextArea {

    public void runCommand(String... command) {
        new Thread(() -> {
            try {
                var process = new ProcessBuilder(command).redirectErrorStream(true).start();
                try (var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
                    String line;
                    while ((line = reader.readLine()) != null) {
                        var output = line + System.lineSeparator();
                        Platform.runLater(() -> appendText(output));
                    }
                }
            } catch (Exception ex) {
                Platform.runLater(() -> appendText(ex.getMessage() + System.lineSeparator()));
            }
        }, "console-reader").start();
    }
}
```

## Setup notes

- A true terminal emulator needs keyboard handling, cursor tracking, and ANSI processing; a plain
  log view is not enough.
- Read process output on background threads and update the UI on the FX thread only.
- Use PTY support when the shell must behave like an interactive terminal instead of a one-shot
  process runner.

## Gotchas

- `TextArea`-only implementations usually break copy/paste, selection, and ANSI color behavior.
- Interactive shells can deadlock if stdin/stdout are not drained carefully.
- Terminal size changes often need explicit propagation to the underlying PTY or process.