fixed app doesn't exit on close, added JFXInfoAlert
* closes #17 * closes #17
This commit is contained in:
parent
40bfc73ba8
commit
9200e9277a
|
@ -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()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ import javafx.scene.text.Text
|
||||||
import tornadofx.FX
|
import tornadofx.FX
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param heading Heading text of the alert
|
* @param heading Heading text of the alert
|
||||||
* @param body Content text of the alert
|
* @param body Content text of the alert
|
||||||
* @param btnStyle Style of the buttons
|
* @param btnStyle Style of the buttons
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hso.texturesyncclient.app
|
package org.hso.texturesyncclient.app
|
||||||
|
|
||||||
|
import javafx.stage.Stage
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupView
|
import org.hso.texturesyncclient.view.startupView.StartupView
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupViewController
|
import org.hso.texturesyncclient.view.startupView.StartupViewController
|
||||||
import tornadofx.App
|
import tornadofx.App
|
||||||
|
@ -9,4 +10,9 @@ class Main: App(StartupView::class){
|
||||||
//start first controller
|
//start first controller
|
||||||
private val svc = StartupViewController()
|
private val svc = StartupViewController()
|
||||||
|
|
||||||
|
override fun start(stage: Stage) {
|
||||||
|
super.start(stage)
|
||||||
|
stage.setOnCloseRequest { System.exit(0) }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue