diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXInfoAlert.kt b/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXInfoAlert.kt new file mode 100644 index 0000000..ce74af7 --- /dev/null +++ b/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXInfoAlert.kt @@ -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(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() + } + +} \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXOkayCancelAlert.kt b/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXOkayCancelAlert.kt index af56396..145766e 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXOkayCancelAlert.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/alerts/JFXOkayCancelAlert.kt @@ -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 diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt b/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt index c2f1c7a..4616f87 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt @@ -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) } + } + } \ No newline at end of file