0

I'm a total beginner trying to create a gui in javafx and I've run into the following problem. I have a textField that accepts user input and a textFlow that displays the input along with other stuff.

I tried to use the textField's ActionEvent to add the user input to the textFlow as an independent Text object, but for some reason this does nothing.

Here is the code in question

        textField.setOnAction((ActionEvent event) -> {
        Text input=new Text(textField.getText());
        textFlow.getChildren().add(input);
        textField.setText("");
        }); 

I used specific names rather than the class names (textField etc.), but I replaced them here for clarity.

If

textArea.appendText(userInput.getText());

is added in the ActionEvent expression, it works fine and transfers the user input to a textArea. However, I need it to be a textFlow for various reasons.

Sotiris
  • 53
  • 11
  • It should work fine. Can you expand the sample code to a [MCVE]? – James_D Mar 15 '16 at 22:05
  • Apparently I was trying to print unformatted text on a black background and hadn't realised it. It's funny how programming makes me realise how stupid I am ._. – Sotiris Mar 17 '16 at 21:26

0 Answers0