gonozalviii/KopperFX

Controller helpers

Opened this issue · 0 comments

Usually I open new windows from controllers, and I use the following extensions to make it easy:

fun <T : Parent> Initializable.load(fxml: String): T = FXMLLoader.load<T>(javaClass.getResource(fxml))
fun Initializable.window(title: String, fxml: String, open: Boolean = true): Stage {
    val stage = Stage()
    stage.title = title
    stage.scene = Scene(load(fxml))
    if (open) stage.show()
    return stage
}