I tried to write my 'own' log in a tab and I experienced problems with updating the label with a naive solution that I had.
So after I googled I checked out this solution here: Displaying changing values in JavaFx Label
I don't know if I did everything right but unfortunately this solution doesn't work for me.
final static Label logLabel = new Label();
final static SimpleStringProperty logString = new SimpleStringProperty("test");
...
...
public void start(Stage primaryStage) {
TabPane tabPane = new TabPane();
tabPane.getTabs().add(createSettingsTab());
tabPane.getTabs().add(createParticipantTab());
tabPane.getTabs().add(createSpectatorTab());
tabPane.getTabs().add(createOverviewTab());
tabPane.getTabs().add(createTournamentTab());
tabPane.getTabs().add(createLogTab());
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
Scene scene = new Scene(tabPane, 1200, 800);
primaryStage.setScene(scene);
primaryStage.setResizable(true);
primaryStage.show();
}
private Tab createLogTab() {
// TODO Auto-generated method stub
logLabel.textProperty().bind(logString);
Tab tab = new Tab("Log");
tab.setContent(logLabel);
return tab;
}
I got this lines for initializing the Label and for setting the new text I do this:
logString.set(logString.get() + "foo");
The log tab keeps being blank...
I'd appreciate any help! Thanks!
edit// That's the only useful mcve I can think of. As I said the other create methods to create the other tabs are not making use of the label or the SimpleStringProperty
This is the button that doesn't work as supposed concerning the label.
buttonLoadConfig.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
System.out.println("test");
logString.set(logString.get() + "\ttest");
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Choose Config");
File config = fileChooser.showOpenDialog(new Stage());
}
});