diff --git a/src/main/java/com/cemu_UI/uiElements/JFXDirStrmCancelDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXDirStrmCancelDialog.java deleted file mode 100644 index 71ec0ee..0000000 --- a/src/main/java/com/cemu_UI/uiElements/JFXDirStrmCancelDialog.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.cemu_UI.uiElements; - -import java.util.ResourceBundle; - -import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXDialog; -import com.jfoenix.controls.JFXDialogLayout; - -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Text; - -public class JFXDirStrmCancelDialog { - private String headingText; - private String bodyText; - private String dialogBtnStyle; - private String btn1Text; - private String btn2Text; - private String cancelText; - private int dialogWidth; - private int dialogHeight; - private EventHandler btn1Action; - private EventHandler btn2Action; - private Pane pane; - - /** - * Creates a new JFoenix Dialog to show some information with okay and cancel - * option - * - * @param headingText Heading Text, just the heading - * @param bodyText body Text, all other text belongs here - * @param dialogBtnStyle Style of the okay button - * @param dialogWidth dialog width - * @param dialogHeight dialog height - * @param btn1Action action which is performed if btn1 is clicked - * @param btn2Action action which is performed if btn2 is clicked - * @param cancelAction action which is performed if the cancel button is clicked - * @param pane pane to which the dialog belongs - */ - public JFXDirStrmCancelDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, - int dialogHeight, EventHandler btn1Action, EventHandler btn2Action, - Pane pane, ResourceBundle bundle) { - setHeadingText(headingText); - setBodyText(bodyText); - setDialogBtnStyle(dialogBtnStyle); - setDialogWidth(dialogWidth); - setDialogHeight(dialogHeight); - setBtn1Action(btn1Action); - setBtn2Action(btn2Action); - setPane(pane); - - btn1Text = bundle.getString("addDirectory"); - btn2Text = bundle.getString("addStreamSource"); - cancelText = bundle.getString("cancelBtnText"); - } - - public JFXDirStrmCancelDialog() { - // Auto-generated constructor stub - } - - public void show() { - JFXDialogLayout content = new JFXDialogLayout(); - content.setHeading(new Text(headingText)); - content.setBody(new Text(bodyText)); - StackPane stackPane = new StackPane(); - stackPane.autosize(); - JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); - - JFXButton btn1 = new JFXButton(btn1Text); - btn1.addEventHandler(ActionEvent.ACTION, (e) -> { - dialog.close(); - }); - btn1.addEventHandler(ActionEvent.ACTION, btn1Action); - btn1.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - btn1.setPrefHeight(32); - btn1.setStyle(dialogBtnStyle); - - JFXButton btn2 = new JFXButton(btn2Text); - btn2.addEventHandler(ActionEvent.ACTION, (e) -> { - dialog.close(); - }); - btn2.addEventHandler(ActionEvent.ACTION, btn2Action); - btn2.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - btn2.setPrefHeight(32); - btn2.setStyle(dialogBtnStyle); - - JFXButton cancelBtn = new JFXButton(cancelText); - cancelBtn.addEventHandler(ActionEvent.ACTION, (e) -> { - dialog.close(); - }); - cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); - cancelBtn.setPrefHeight(32); - cancelBtn.setStyle(dialogBtnStyle); - - content.setActions(cancelBtn, btn1, btn2); - content.setPrefSize(dialogWidth, dialogHeight); - pane.getChildren().add(stackPane); - AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2); - AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2); - dialog.show(); - } - - public String getHeadingText() { - return headingText; - } - - public void setHeadingText(String headingText) { - this.headingText = headingText; - } - - public String getBodyText() { - return bodyText; - } - - public void setBodyText(String bodyText) { - this.bodyText = bodyText; - } - - public String getDialogBtnStyle() { - return dialogBtnStyle; - } - - public void setDialogBtnStyle(String dialogBtnStyle) { - this.dialogBtnStyle = dialogBtnStyle; - } - - public String getBtn1Text() { - return btn1Text; - } - - public void setBtn1Text(String btn1Text) { - this.btn1Text = btn1Text; - } - - public String getBtn2Text() { - return btn2Text; - } - - public void setBtn2Text(String btn2Text) { - this.btn2Text = btn2Text; - } - - public String getCancelText() { - return cancelText; - } - - public void setCancelText(String cancelText) { - this.cancelText = cancelText; - } - - public int getDialogWidth() { - return dialogWidth; - } - - public void setDialogWidth(int dialogWidth) { - this.dialogWidth = dialogWidth; - } - - public int getDialogHeight() { - return dialogHeight; - } - - public void setDialogHeight(int dialogHeight) { - this.dialogHeight = dialogHeight; - } - - public EventHandler getBtn1Action() { - return btn1Action; - } - - public void setBtn1Action(EventHandler btn1Action) { - this.btn1Action = btn1Action; - } - - public EventHandler getBtn2Action() { - return btn2Action; - } - - public void setBtn2Action(EventHandler btn2Action) { - this.btn2Action = btn2Action; - } - - public Pane getPane() { - return pane; - } - - public void setPane(Pane pane) { - this.pane = pane; - } - -} diff --git a/src/main/java/kellerkinder/HomeFlix/application/Main.java b/src/main/java/kellerkinder/HomeFlix/application/Main.java index df01890..ee36ce5 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/Main.java +++ b/src/main/java/kellerkinder/HomeFlix/application/Main.java @@ -25,35 +25,25 @@ package kellerkinder.HomeFlix.application; import java.io.File; import java.io.IOException; import java.util.Locale; -import java.util.Optional; 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 org.kellerkinder.Alerts.JFX2BtnCancelAlert; 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; -import javafx.scene.control.Alert.AlertType; -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 { - + private Stage primaryStage; private Scene scene; private AnchorPane pane; @@ -64,29 +54,29 @@ public class Main extends Application { private static String osArch = System.getProperty("os.arch"); private static String osVers = System.getProperty("os.version"); private static String javaVers = System.getProperty("java.version"); - private static String javaVend= System.getProperty("java.vendor"); - private String dirWin = userHome + "/Documents/HomeFlix"; //Windows: C:/Users/"User"/Documents/HomeFlix - private String dirLinux = userHome + "/HomeFlix"; //Linux: /home/"User"/HomeFlix + private static String javaVend = System.getProperty("java.vendor"); + private String dirWin = userHome + "/Documents/HomeFlix"; // Windows: C:/Users/"User"/Documents/HomeFlix + private String dirLinux = userHome + "/HomeFlix"; // Linux: /home/"User"/HomeFlix private File directory; private File configFile; private File posterCache; - + private String FONT_FAMILY = "System"; - private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country"); + private String local = System.getProperty("user.language") + "_" + System.getProperty("user.country"); private double FONT_SIZE = 17; private ResourceBundle bundle; private static Logger LOGGER; - + @Override public void start(Stage primaryStage) throws IOException { LOGGER.info("OS: " + osName + " " + osVers + " " + osArch); LOGGER.info("Java: " + javaVend + " " + javaVers); LOGGER.info("User: " + userName + " " + userHome); - - this.primaryStage = primaryStage; + + this.primaryStage = primaryStage; mainWindow(); } - + private void mainWindow(){ try { FXMLLoader loader = new FXMLLoader(); @@ -133,12 +123,6 @@ 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 - // init here as it loads the games to the mwc and the gui, therefore the window must exist mainWindowController.init(); mainWindowController.getDbController().init(); @@ -146,11 +130,12 @@ public class Main extends Application { LOGGER.error(e); } } - - /** TODO add option to add streaming as first source - * when there i no config.xml we need to get the path for the first source from the user + + /** + * TODO add option to add streaming as first source when there i no config.xml + * we need to get the path for the first source from the user */ - private void getFirstSource(){ + private void getFirstSource() { switch (System.getProperty("user.language") + "_" + System.getProperty("user.country")) { case "en_US": bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english @@ -163,85 +148,56 @@ public class Main extends Application { break; } -// // directory action -// EventHandler btn1Action = new EventHandler() { -// @Override -// public void handle(ActionEvent event) { -// DirectoryChooser directoryChooser = new DirectoryChooser(); -// directoryChooser.setTitle(bundle.getString("addDirectory")); -// File selectedFolder = directoryChooser.showDialog(primaryStage); -// if (selectedFolder != null && selectedFolder.exists()) { -// mainWindowController.addSource(selectedFolder.getPath(), "local"); -// } else { -// LOGGER.error("The selected folder dosen't exist!"); -// } -// } -// }; -// -// // streaming action -// EventHandler btn2Action = new EventHandler() { -// @Override -// public void handle(ActionEvent event) { -// FileChooser fileChooser = new FileChooser(); -// fileChooser.setTitle("addStreamSource"); -// File selectedFile = fileChooser.showOpenDialog(getPrimaryStage()); -// if (selectedFile != null && selectedFile.exists()) { -// mainWindowController.addSource(selectedFile.getPath(), "stream"); -// } else { -// LOGGER.error("The selected file dosen't exist!"); -// } -// } -// }; -// -// 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"); - alert.setHeaderText(bundle.getString("addSourceHeader")); - alert.setContentText(bundle.getString("addSourceBody")); - alert.setResizable(true); - - ButtonType buttonDirectory = new ButtonType(bundle.getString("addDirectory")); - ButtonType buttonStreaming = new ButtonType(bundle.getString("addStreamSource")); - ButtonType buttonCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); + JFX2BtnCancelAlert selectFirstSource = new JFX2BtnCancelAlert(bundle.getString("addSourceHeader"), + bundle.getString("addSourceBody"), + "-fx-button-type: RAISED; -fx-background-color: #ee3523; -fx-text-fill: BLACK;", + bundle.getString("addDirectory"), bundle.getString("addStreamSource"), + bundle.getString("cancelBtnText"), primaryStage); - alert.getButtonTypes().setAll(buttonDirectory, buttonStreaming, buttonCancel); + // directory action + EventHandler btn1Action = new EventHandler() { + @Override + public void handle(ActionEvent event) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle(bundle.getString("addDirectory")); + File selectedFolder = directoryChooser.showDialog(primaryStage); + if (selectedFolder != null && selectedFolder.exists()) { + mainWindowController.addSource(selectedFolder.getPath(), "local"); + selectFirstSource.getAlert().close(); + } else { + LOGGER.error("The selected folder dosen't exist!"); + System.exit(1); + } + } + }; - Optional result = alert.showAndWait(); - if (result.get() == buttonDirectory) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - directoryChooser.setTitle(bundle.getString("addDirectory")); - File selectedFolder = directoryChooser.showDialog(primaryStage); - if (selectedFolder != null && selectedFolder.exists()) { - mainWindowController.addSource(selectedFolder.getPath(), "local"); - } else { - LOGGER.error("The selected folder dosen't exist!"); - System.exit(1); + // streaming action + EventHandler btn2Action = new EventHandler() { + @Override + public void handle(ActionEvent event) { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("addStreamSource"); + File selectedFile = fileChooser.showOpenDialog(getPrimaryStage()); + if (selectedFile != null && selectedFile.exists()) { + mainWindowController.addSource(selectedFile.getPath(), "stream"); + selectFirstSource.getAlert().close(); + } else { + LOGGER.error("The selected file dosen't exist!"); + System.exit(1); + } } - } else if (result.get() == buttonStreaming) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("addStreamSource"); - File selectedFile = fileChooser.showOpenDialog(getPrimaryStage()); - if (selectedFile != null && selectedFile.exists()) { - mainWindowController.addSource(selectedFile.getPath(), "stream"); - } else { - LOGGER.error("The selected file dosen't exist!"); - System.exit(1); - } - } else { - LOGGER.warn("No source selected!"); - System.exit(1); - } + }; + selectFirstSource.setBtn1Action(btn1Action); + selectFirstSource.setBtn2Action(btn2Action); + selectFirstSource.showAndWait(); } public static void main(String[] args) { - if(System.getProperty("os.name").equals("Windows")){ + if (System.getProperty("os.name").equals("Windows")) { System.setProperty("logFilename", userHome + "/Documents/HomeFlix/app.log"); File logFile = new File(userHome + "/Documents/HomeFlix/app.log"); logFile.delete(); - }else{ + } else { System.setProperty("logFilename", userHome + "/HomeFlix/app.log"); File logFile = new File(userHome + "/HomeFlix/app.log"); logFile.delete(); @@ -257,8 +213,8 @@ public class Main extends Application { public void setPrimaryStage(Stage primaryStage) { this.primaryStage = primaryStage; } - - public AnchorPane getPane( ) { + + public AnchorPane getPane() { return pane; } @@ -269,7 +225,7 @@ public class Main extends Application { public void setFONT_FAMILY(String FONT_FAMILY) { this.FONT_FAMILY = FONT_FAMILY; } - + public File getDirectory() { return directory; } diff --git a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java index 83dc315..2001c43 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java +++ b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java @@ -44,6 +44,7 @@ import java.util.ResourceBundle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.kellerkinder.Alerts.JFXInfoAlert; import com.cemu_UI.uiElements.JFXInfoDialog; import com.eclipsesource.json.Json; @@ -231,9 +232,9 @@ public class MainWindowController { private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); private int hashA = -647380320; - private String version = "0.6.0"; - private String buildNumber = "141"; - private String versionName = "plasma vampire"; + private String version = "0.6.1"; + private String buildNumber = "145"; + private String versionName = "glowing vampire"; private String dialogBtnStyle; private String color; private String title; @@ -609,8 +610,8 @@ public class MainWindowController { private void aboutBtnAction() { String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (Build: " + buildNumber + ") \"" + versionName + "\" \n" + infoText; - JFXInfoDialog aboutDialog = new JFXInfoDialog("Project HomeFlix", bodyText, dialogBtnStyle, 350, 200, main.getPane()); - aboutDialog.show(); + JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, dialogBtnStyle, main.getPrimaryStage()); + infoAlert.showAndWait(); } @FXML diff --git a/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java b/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java new file mode 100644 index 0000000..8272b1d --- /dev/null +++ b/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java @@ -0,0 +1,190 @@ +/** + * Kellerkinder Framework Alerts + * + * Copyright 2018 <@Seil0> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +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.scene.text.Text; +import javafx.stage.Stage; + +public class JFX2BtnCancelAlert { + + private String headingText; + private String bodyText; + private String btnStyle; + private String btn1Text; + private String btn2Text; + private String cancelText; + private EventHandler btn1Action; + private EventHandler btn2Action; + private Stage stage; + private JFXAlert alert; + + /** + * Creates a new JFoenix Alert with 2 buttons and one cancel button + * @param titleText Title text of the alert + * @param headerText Heading text of the alert + * @param contentText Content text of the alert + * @param btnStyle Style of the okay button + * @param btn1Text btn1 text + * @param btn2Text btn2 text + * @param cancelText cancel button text + * @param stage stage to which the dialog belongs + */ + public JFX2BtnCancelAlert(String headingText, String bodyText, String btnStyle, String btn1Text, String btn2Text, + String cancelText, Stage stage) { + setHeadingText(headingText); + setBodyText(bodyText); + setBtnStyle(btnStyle); + setBtn1Text(btn1Text); + setBtn2Text(btn2Text); + setCancelText(cancelText); + setStage(stage); + } + + public JFX2BtnCancelAlert() { + // Auto-generated constructor stub + } + + public void showAndWait() { + alert = new JFXAlert<>(stage); + + JFXButton btnOne = new JFXButton(); + + btnOne.setText(btn1Text); + btnOne.setOnAction(btn1Action); + btnOne.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + btnOne.setPrefHeight(32); + btnOne.setStyle(btnStyle); + + JFXButton btnTwo = new JFXButton(); + btnTwo.setText(btn2Text); + btnTwo.setOnAction(btn2Action); + btnTwo.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + btnTwo.setPrefHeight(32); + btnTwo.setStyle(btnStyle); + + JFXButton cancelBtn = new JFXButton(); + cancelBtn.setText(cancelText); + cancelBtn.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + alert.close(); + System.exit(1); + } + }); + cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); + cancelBtn.setPrefHeight(32); + cancelBtn.setStyle(btnStyle); + + JFXDialogLayout content = new JFXDialogLayout(); + content.setActions(btnOne, btnTwo, cancelBtn); + content.setHeading(new Text(headingText)); + content.setBody(new Text(bodyText)); + alert.setContent(content); + alert.showAndWait(); + } + + public String getHeadingText() { + return headingText; + } + + public void setHeadingText(String headingText) { + this.headingText = headingText; + } + + public String getBodyText() { + return bodyText; + } + + public void setBodyText(String bodyText) { + this.bodyText = bodyText; + } + + public String getBtnStyle() { + return btnStyle; + } + + public void setBtnStyle(String btnStyle) { + this.btnStyle = btnStyle; + } + + public String getBtn1Text() { + return btn1Text; + } + + public void setBtn1Text(String btn1Text) { + this.btn1Text = btn1Text; + } + + public String getBtn2Text() { + return btn2Text; + } + + public void setBtn2Text(String btn2Text) { + this.btn2Text = btn2Text; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + + public EventHandler getBtn1Action() { + return btn1Action; + } + + public void setBtn1Action(EventHandler btn1Action) { + this.btn1Action = btn1Action; + } + + public EventHandler getBtn2Action() { + return btn2Action; + } + + public void setBtn2Action(EventHandler btn2Action) { + this.btn2Action = btn2Action; + } + + public Stage getStage() { + return stage; + } + + public void setStage(Stage stage) { + this.stage = stage; + } + + public JFXAlert getAlert() { + return alert; + } + + public void setAlert(JFXAlert alert) { + this.alert = alert; + } +} diff --git a/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java b/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java index 62b8ce7..2375b4d 100644 --- a/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java +++ b/src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java @@ -1,3 +1,24 @@ +/** + * Kellerkinder Framework Alerts + * + * Copyright 2018 <@Seil0> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + package org.kellerkinder.Alerts; import com.jfoenix.controls.JFXAlert; @@ -6,33 +27,36 @@ import com.jfoenix.controls.JFXDialogLayout; import javafx.event.ActionEvent; import javafx.event.EventHandler; +import javafx.scene.text.Text; import javafx.stage.Stage; public class JFXInfoAlert { - private String titleText; - private String headerText; - private String contentText; + private String headingText; + private String bodyText; private String btnStyle; private Stage stage; + + /** + * Creates a new JFoenix Alert to show some information + * @param headerText Heading text of the alert + * @param bodyText Content text of the alert + * @param btnStyle Style of the okay button + * @param stage stage to which the dialog belongs + */ + public JFXInfoAlert(String headingText, String bodyText, String btnStyle, Stage stage) { + setHeadingText(headingText); + setBodyText(bodyText); + setBtnStyle(btnStyle); + setStage(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() { @@ -47,32 +71,26 @@ public class JFXInfoAlert { JFXDialogLayout content = new JFXDialogLayout(); content.setActions(button); + content.setHeading(new Text(headingText)); + content.setBody(new Text(bodyText)); alert.setContent(content); alert.showAndWait(); } - public String getTitleText() { - return titleText; + public String getHeadingText() { + return headingText; } - public void setTitleText(String titleText) { - this.titleText = titleText; + public void setHeadingText(String headingText) { + this.headingText = headingText; } - public String getHeaderText() { - return headerText; + public String getBodyText() { + return bodyText; } - public void setHeaderText(String headerText) { - this.headerText = headerText; - } - - public String getContentText() { - return contentText; - } - - public void setContentText(String contentText) { - this.contentText = contentText; + public void setBodyText(String bodyText) { + this.bodyText = bodyText; } public String getBtnStyle() { @@ -91,4 +109,4 @@ public class JFXInfoAlert { this.stage = stage; } -} +} \ No newline at end of file