Source:
public ConsoleWindow() throws CommandInterpreterException { commandInterpreter = commandInterpreterFactory.createInstance(); final VBox rootPane = new VBox(); final TextField command = new TextField(); command.getStyleClass().add("consoleCommandType"); final TextFlow console = new TextFlow(); final ScrollPane consolePane = new ScrollPane(console); rootPane.getStyleClass().add("consoleWindow"); consolePane.getStyleClass().add("console"); consolePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); rootPane.getChildren().addAll(consolePane, command); Scene scene = new PlayOnLinuxScene(rootPane); this.setScene(scene); this.setTitle(translate("${application.name} console")); this.show(); command.requestFocus(); command.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.ENTER) { final String commandToSend = command.getText(); command.setDisable(true); commandHistory.add(commandToSend); historyIndex++; Text commandText = new Text(nextSymbol + commandToSend + "\n"); commandText.getStyleClass().add("commandText"); console.getChildren().add(commandText); command.setText(""); if (commandInterpreter.sendLine(commandToSend, message -> Platform.runLater(() -> { if (!StringUtils.isBlank(message)) { Text resultText = new Text(message); resultText.getStyleClass().add("resultText"); console.getChildren().add(resultText); } command.setDisable(false); command.requestFocus(); consolePane.setVvalue(consolePane.getVmax()); }))) { nextSymbol = NOT_INSIDE_BLOCK; } else { nextSymbol = INSIDE_BLOCK; } }else if(event.getCode() == KeyCode.UP && historyIndex > 0){ historyIndex--; System.out.println("HistoryIndex: " + historyIndex); command.setText(commandHistory.get(historyIndex)); }else if(event.getCode() == KeyCode.DOWN){ historyIndex++; if(historyIndex == commandHistory.size()){ command.setText(""); }else if(historyIndex < commandHistory.size()){ System.out.println("HistoryIndex: " + historyIndex); command.setText(commandHistory.get(historyIndex)); }else { historyIndex = commandHistory.size(); } } }); this.setOnCloseRequest(event -> commandInterpreter.close()); }

Target:
public ConsoleWindow() throws CommandInterpreterException { commandInterpreter = commandInterpreterFactory.createInstance(); final VBox rootPane = new VBox(); final TextField command = new TextField(); command.getStyleClass().add("consoleCommandType"); final TextFlow console = new TextFlow(); final ScrollPane consolePane = new ScrollPane(console); rootPane.getStyleClass().add("consoleWindow"); consolePane.getStyleClass().add("console"); consolePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); rootPane.getChildren().addAll(consolePane, command); Scene scene = new PlayOnLinuxScene(rootPane); this.setScene(scene); this.setTitle(translate("${application.name} console")); this.show(); command.requestFocus(); command.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.ENTER) { final String commandToSend = command.getText(); command.setDisable(true); commandHistory.add(commandToSend); historyIndex++; Text commandText = new Text(nextSymbol + commandToSend + "\n"); commandText.getStyleClass().add("commandText"); console.getChildren().add(commandText); command.setText(""); if (commandInterpreter.sendLine(commandToSend, message -> Platform.runLater(() -> { if (!StringUtils.isBlank(message)) { Text resultText = new Text(message); resultText.getStyleClass().add("resultText"); console.getChildren().add(resultText); } command.setDisable(false); command.requestFocus(); consolePane.setVvalue(consolePane.getVmax()); }))) { nextSymbol = NOT_INSIDE_BLOCK; } else { nextSymbol = INSIDE_BLOCK; } } else if (event.getCode() == KeyCode.UP && historyIndex > 0) { historyIndex--; command.setText(commandHistory.get(historyIndex)); } else if (event.getCode() == KeyCode.DOWN) { historyIndex++; if (historyIndex == commandHistory.size()) { command.setText(""); } else if (historyIndex < commandHistory.size()) { command.setText(commandHistory.get(historyIndex)); } else { historyIndex = commandHistory.size(); } } }); this.setOnCloseRequest(event -> commandInterpreter.close()); }