Reputation: 128
I want the code in execute()
to be executed when the window the controller belongs to is opened. How would I do so?
public class OpenAccountScreenController {
public TableView openAccountTableView = new TableView();
public TableColumn accountNameColumn = new TableColumn();
public TableColumn accountNumberColumn = new TableColumn();
public void execute() {
accountNameColumn.setCellValueFactory(new PropertyValueFactory("accountName"));
accountNumberColumn.setCellValueFactory(new PropertyValueFactory("accountNumber"));
for(Account account : accounts.values()) {
openAccountTableView.getItems().add(account);
}
}
}
Upvotes: 0
Views: 1024
Reputation: 14072
If I understand your question properly that you want to call execute()
in another class once the Window/Stage is shown, so you can do something like this:
OpenAccountScreenController obj = new OpenAccountScreenController();
stage.setOnShowing(e-> obj.execute());
Otherwise please clarify.
Upvotes: 1