added info alert

This commit is contained in:
Jannik 2018-03-29 12:27:44 +02:00
parent 8ec7653a5e
commit 34371bb2b5
2 changed files with 113 additions and 6 deletions

View File

@ -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");

View File

@ -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<Void> alert = new JFXAlert<>(stage);
alert.setTitle(titleText);
alert.setHeaderText(headerText);
alert.setContentText(contentText);
JFXButton button = new JFXButton("Okay");
button.setOnAction(new EventHandler<ActionEvent>() {
@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;
}
}