fixed app doesn't exit on close, added JFXInfoAlert
* closes #17 * closes #17
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 * @param heading   Heading text of the alert
 | 
			
		||||
 * @param body      Content text of the alert
 | 
			
		||||
 * @param btnStyle  Style of the buttons
 | 
			
		||||
 | 
			
		||||
@ -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) }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user