-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Own class for loading scene for better code
- Loading branch information
AdrianBalunan
committed
Mar 13, 2026
1 parent
6afdd4e
commit 5adb369
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/LoaderScene.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package ntnu.systemutvikling.team6.controller; | ||
|
|
||
| import javafx.event.ActionEvent; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Node; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.Scene; | ||
| import javafx.stage.Stage; | ||
| import ntnu.systemutvikling.team6.HmHApplication; | ||
| import ntnu.systemutvikling.team6.models.Charity; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class LoaderScene { | ||
| public static void LoadScene(String sceneName, ActionEvent event, Charity charity){ | ||
| try { | ||
| System.out.println(HmHApplication.class.getResource("/fxml/"+ sceneName +".fxml")); | ||
| FXMLLoader fxmlLoader = | ||
| new FXMLLoader(HmHApplication.class.getResource("/fxml/"+ sceneName +".fxml")); | ||
| Parent root = fxmlLoader.load(); | ||
|
|
||
| System.out.println("Controller: " + fxmlLoader.getController()); | ||
| DonationPageController controller = fxmlLoader.getController(); | ||
| controller.setCharity(charity); | ||
|
|
||
| Stage stage = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
| Scene scene = new Scene(root); | ||
| stage.setScene(scene); | ||
| stage.setFullScreen(true); | ||
| stage.show(); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } |