Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds JavaFX terminal emulators and shell-style console panes with background process I/O and ANSI handling.
Use this skill ↓100% 95%−5 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 22 of 22 without it.
3 of 3 safety checks passed
Not used yet
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.
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();
}
}
Next to this one in the catalogue, plus more from the same author.