fixed app doesn't exit on close, added JFXInfoAlert

* closes #17
* closes #17
This commit is contained in:
Jannik 2019-06-08 12:09:40 +02:00
parent 40bfc73ba8
commit 9200e9277a
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
3 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,39 @@
package org.hso.texturesyncclient.alerts
import com.jfoenix.controls.JFXDialogLayout
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXAlert
import javafx.event.ActionEvent
import javafx.scene.text.Text
import tornadofx.FX
/**
* Creates a new JFoenix Alert to show some information
* @param heading Heading text of the alert
* @param body Content text of the alert
* @param btnStyle Style of the okay button
*/
class JFXInfoAlert(heading: String, body: String, private var btnStyle: String) {
private var headingText = Text(heading)
private var bodyText = Text(body)
fun showAndWait() {
val alert = JFXAlert<Void>(FX.primaryStage)
val button = JFXButton("Okay")
button.addEventHandler(ActionEvent.ACTION) { alert.close() }
button.buttonType = JFXButton.ButtonType.RAISED
button.prefHeight = 32.0
button.style = btnStyle
val content = JFXDialogLayout()
content.setActions(button)
content.setHeading(headingText)
content.setBody(bodyText)
alert.setContent(content)
alert.showAndWait()
}
}

View File

@ -10,7 +10,6 @@ import javafx.scene.text.Text
import tornadofx.FX
/**
*
* @param heading Heading text of the alert
* @param body Content text of the alert
* @param btnStyle Style of the buttons

View File

@ -1,5 +1,6 @@
package org.hso.texturesyncclient.app
import javafx.stage.Stage
import org.hso.texturesyncclient.view.startupView.StartupView
import org.hso.texturesyncclient.view.startupView.StartupViewController
import tornadofx.App
@ -9,4 +10,9 @@ class Main: App(StartupView::class){
//start first controller
private val svc = StartupViewController()
override fun start(stage: Stage) {
super.start(stage)
stage.setOnCloseRequest { System.exit(0) }
}
}