@ -1,7 +1,7 @@
/ * *
* cemu_UI
* Kellerkinder Framework Alerts
*
* Copyright 2017 - 201 8 < @Seil0 >
* 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
@ -20,66 +20,92 @@
* /
package com.cemu_UI.uiElements ;
import com.jfoenix.controls.JFXAlert ;
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 ;
import javafx.stage.Stage ;
public class JFXInfoDialog {
public class JFXInfoAlert {
private String headingText ;
private String bodyText ;
private String dialogBtnStyle ;
private int dialogWidth ;
private int dialogHeight ;
private Pane pane ;
private String btnStyle ;
private Stage stage ;
/ * *
* Creates a new JFoenix Dialog to show some information
* @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 pane pane to which the dialog belongs
* 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 JFXInfoDialog ( String headingText , String bodyText , String dialogBtnStyle , int dialogWidth , int dialogHeight , Pane pane ) {
this . headingText = headingText ;
this . bodyText = bodyText ;
this . dialogBtnStyle = dialogBtnStyle ;
this . dialogWidth = dialogWidth ;
this . dialogHeight = dialogHeight ;
this . pane = pane ;
public JFXInfoAlert ( String headingText , String bodyText , String btnStyle , Stage stage ) {
setHeadingText ( headingText ) ;
setBodyText ( bodyText ) ;
setBtnStyle ( btnStyle ) ;
setStage ( stage ) ;
}
public void show ( ) {
JFXDialogLayout content = new JFXDialogLayout ( ) ;
content . setHeading ( new Text ( headingText ) ) ;
content . setBody ( new Text ( bodyText ) ) ;
content . setPrefSize ( dialogWidth , dialogHeight ) ;
StackPane stackPane = new StackPane ( ) ;
stackPane . autosize ( ) ;
JFXDialog dialog = new JFXDialog ( stackPane , content , JFXDialog . DialogTransition . LEFT , true ) ;
public JFXInfoAlert ( ) {
// Auto-generated constructor stub
}
public void showAndWait ( ) {
JFXAlert < Void > alert = new JFXAlert < > ( stage ) ;
JFXButton button = new JFXButton ( "Okay" ) ;
button . setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
dialog . close ( ) ;
alert . close ( ) ;
}
} ) ;
button . setButtonType ( com . jfoenix . controls . JFXButton . ButtonType . RAISED ) ;
button . setPrefHeight ( 32 ) ;
button . setStyle ( dialogBtnStyle ) ;
button . setStyle ( btnStyle ) ;
JFXDialogLayout content = new JFXDialogLayout ( ) ;
content . setActions ( button ) ;
pane . getChildren ( ) . add ( stackPane ) ;
AnchorPane . setTopAnchor ( stackPane , ( pane . getHeight ( ) - content . getPrefHeight ( ) ) / 2 ) ;
AnchorPane . setLeftAnchor ( stackPane , ( pane . getWidth ( ) - content . getPrefWidth ( ) ) / 2 ) ;
dialog . show ( ) ;
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 Stage getStage ( ) {
return stage ;
}
public void setStage ( Stage stage ) {
this . stage = stage ;
}
}
}