Reputation: 793
I have created a UI for my application using "JavaFX Scene Builder".
I need to show text inside the TextFlow object so in my class (implements javafx.fxml.Initializable ) I write this
public void initialize(URL location, ResourceBundle resources)
{
Text t1 = new Text("My name is Josh!");
tofl = new TextFlow(t1);
}
This way my TextFlow object does not show the Text at all. Should I call a method on tofl
like tofl.apply()
to let the text appear?
TextFlow is initialized as a fieldabove the method, it is all linked with fxlm file too. Using TextArea everything works fine instead.
Upvotes: 2
Views: 7821
Reputation: 36722
You are re-initializing your TextFlow
to a new TextFlow object
. You should never do that with fields linked with @FXML
If you want to add Text
to the textFlow(defined in your FXML), use :
public void initialize(URL location, ResourceBundle resources)
{
Text t1 = new Text("My name is Josh!");
tofl.getChildren().add(t1);
}
Upvotes: 5