Browse Source

added info alert

pull/24/head
Jannik 4 years ago
parent
commit
34371bb2b5
  1. 25
      src/main/java/kellerkinder/HomeFlix/application/Main.java
  2. 94
      src/main/java/org/kellerkinder/Alerts/JFXInfoAlert.java

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

94
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<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;
}
}
Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close