diff --git a/src/main/java/kellerkinder/HomeFlix/application/Main.java b/src/main/java/kellerkinder/HomeFlix/application/Main.java index ceb0877..df01890 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/Main.java +++ b/src/main/java/kellerkinder/HomeFlix/application/Main.java @@ -31,7 +31,13 @@ import java.util.ResourceBundle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.jfoenix.controls.JFXAlert; +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXDialogLayout; + import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.control.Alert; @@ -40,8 +46,10 @@ import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; import javafx.scene.image.Image; import javafx.scene.layout.AnchorPane; +import javafx.scene.text.Text; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; +import javafx.stage.Modality; import javafx.stage.Stage; public class Main extends Application { @@ -104,6 +112,12 @@ public class Main extends Application { posterCache = new File(dirLinux + "/posterCache"); } + // generate window + scene = new Scene(pane); // create new scene, append pane to scene + scene.getStylesheets().add(getClass().getResource("/css/MainWindow.css").toExternalForm()); + primaryStage.setScene(scene); // append scene to stage + primaryStage.show(); // show stage + // startup checks if (!configFile.exists()) { directory.mkdir(); @@ -119,11 +133,11 @@ public class Main extends Application { posterCache.mkdir(); } - // generate window - scene = new Scene(pane); // create new scene, append pane to scene - scene.getStylesheets().add(getClass().getResource("/css/MainWindow.css").toExternalForm()); - primaryStage.setScene(scene); // append scene to stage - primaryStage.show(); // show stage +// // generate window +// scene = new Scene(pane); // create new scene, append pane to scene +// scene.getStylesheets().add(getClass().getResource("/css/MainWindow.css").toExternalForm()); +// primaryStage.setScene(scene); // append scene to stage +// primaryStage.show(); // show stage // init here as it loads the games to the mwc and the gui, therefore the window must exist mainWindowController.init(); @@ -182,7 +196,6 @@ public class Main extends Application { // JFXDirStrmCancelDialog selectFirstSource = new JFXDirStrmCancelDialog(bundle.getString("addSourceHeader"), // bundle.getString("addSourceBody"), "", 200, 100, btn1Action, btn2Action, pane, bundle); // selectFirstSource.show(); - Alert alert = new Alert(AlertType.CONFIRMATION); //new alert with DirectoryChooser alert.setTitle("Project HomeFlix"); diff --git a/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java b/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java new file mode 100644 index 0000000..62b8ce7 --- /dev/null +++ b/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java @@ -0,0 +1,94 @@ +package org.kellerkinder.Alerts; + +import com.jfoenix.controls.JFXAlert; +import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXDialogLayout; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.stage.Stage; + +public class JFXInfoAlert { + + private String titleText; + private String headerText; + private String contentText; + private String btnStyle; + private Stage stage; + + public JFXInfoAlert() { + // Auto-generated constructor stub + } + + public JFXInfoAlert(String titleText, String headerText, String contentText, String btnStyle, Stage stage) { + setTitleText(titleText); + setHeaderText(headerText); + setContentText(contentText); + setBtnStyle(btnStyle); + setStage(stage); + } + + public void showAndWait( ) { + JFXAlert alert = new JFXAlert<>(stage); + alert.setTitle(titleText); + alert.setHeaderText(headerText); + alert.setContentText(contentText); + + JFXButton button = new JFXButton("Okay"); + button.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + alert.close(); + } + }); + button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + button.setPrefHeight(32); + button.setStyle(btnStyle); + + JFXDialogLayout content = new JFXDialogLayout(); + content.setActions(button); + alert.setContent(content); + alert.showAndWait(); + } + + public String getTitleText() { + return titleText; + } + + public void setTitleText(String titleText) { + this.titleText = titleText; + } + + public String getHeaderText() { + return headerText; + } + + public void setHeaderText(String headerText) { + this.headerText = headerText; + } + + public String getContentText() { + return contentText; + } + + public void setContentText(String contentText) { + this.contentText = contentText; + } + + public String getBtnStyle() { + return btnStyle; + } + + public void setBtnStyle(String btnStyle) { + this.btnStyle = btnStyle; + } + + public Stage getStage() { + return stage; + } + + public void setStage(Stage stage) { + this.stage = stage; + } + +}