2017-11-11 22:27:19 +01:00
/ * *
2018-06-12 16:01:21 +02:00
* Kellerkinder Framework Alerts
2017-11-11 22:27:19 +01:00
*
2018-06-12 16:01:21 +02:00
* Copyright 2018 < @Seil0 >
2017-11-11 22:27:19 +01:00
*
* 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 .
* /
2017-11-13 16:44:39 +01:00
package com.cemu_UI.uiElements ;
2017-11-10 17:11:19 +01:00
2018-06-12 16:01:21 +02:00
import com.jfoenix.controls.JFXAlert ;
2017-11-10 17:11:19 +01:00
import com.jfoenix.controls.JFXButton ;
import com.jfoenix.controls.JFXDialogLayout ;
import javafx.event.ActionEvent ;
import javafx.event.EventHandler ;
import javafx.scene.text.Text ;
2018-06-12 16:01:21 +02:00
import javafx.stage.Stage ;
2017-11-10 17:11:19 +01:00
2018-06-12 16:01:21 +02:00
public class JFXInfoAlert {
2017-11-10 17:11:19 +01:00
private String headingText ;
private String bodyText ;
2018-06-12 16:01:21 +02:00
private String btnStyle ;
private Stage stage ;
2017-11-10 17:11:19 +01:00
2017-11-11 22:27:19 +01:00
/ * *
2018-06-12 16:01:21 +02:00
* 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
2017-11-11 22:27:19 +01:00
* /
2018-06-12 16:01:21 +02:00
public JFXInfoAlert ( String headingText , String bodyText , String btnStyle , Stage stage ) {
setHeadingText ( headingText ) ;
setBodyText ( bodyText ) ;
setBtnStyle ( btnStyle ) ;
setStage ( stage ) ;
2017-11-10 17:11:19 +01:00
}
2018-06-12 16:01:21 +02:00
public JFXInfoAlert ( ) {
// Auto-generated constructor stub
}
public void showAndWait ( ) {
JFXAlert < Void > alert = new JFXAlert < > ( stage ) ;
2017-11-10 17:11:19 +01:00
JFXButton button = new JFXButton ( " Okay " ) ;
button . setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
2018-06-12 16:01:21 +02:00
alert . close ( ) ;
2017-11-10 17:11:19 +01:00
}
} ) ;
button . setButtonType ( com . jfoenix . controls . JFXButton . ButtonType . RAISED ) ;
button . setPrefHeight ( 32 ) ;
2018-06-12 16:01:21 +02:00
button . setStyle ( btnStyle ) ;
JFXDialogLayout content = new JFXDialogLayout ( ) ;
2017-11-10 17:11:19 +01:00
content . setActions ( button ) ;
2018-06-12 16:01:21 +02:00
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 ;
2017-11-10 17:11:19 +01:00
}
2018-06-12 16:01:21 +02:00
}