I have a TableView item that when clicked will launch a Toast. The first parameter is the primary stage from the Main application class.
tableViewPriority.setOnMouseClicked(event -> {
if (tableViewPriority.getSelectionModel().getSelectedItem() != null) {
Toast.makeText(primaryStage, "Toast!", 0, 1, 1);
}
});
How can I get the primaryStage from my Main class into my controller?
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
// Select main layout file
Parent root = FXMLLoader.load(getClass().getResource("/fxml/scene.fxml"));
// Add custom stylesheet URL
root.getStylesheets().add(getClass().getResource("/css/stylesheet.css").toExternalForm());
// Set Scene window params
primaryStage.setTitle("React");
primaryStage.setScene(new Scene(root, 1150, 600));
primaryStage.setResizable(false);
// Set task bar primary icon
primaryStage.getIcons().add(new javafx.scene.image.Image("/images/react-app-icon.png"));
// Show Scene
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}