OS includes basic IO and window management supports.
But we often want higher level of abstraction - or more capablilities - than what OS is providing us with.
Programming language does not provide this higher level of abstraction :/
Toolkit is set of classes/components for building applications provided by multiple sources.
Low-level toolkits:
High-level toolkits:
Also they often provide widgets that can be reused in any application
Add JavaFX to a Project by modifying build.config file
JavaFx imposes a workflow
import javafx.application.Application
import javafx.stage.Stage
class Stages: Application(){
override fun init(){ // [1]: init() - optional
super.init();
println("init")
}
override fun start(stage: Stage){ // [2]: required
println("start")
}
override fun stop(){ // [3]: stop() - optional
super.stop()
pprintln("stop")
}
}
Hello JavaFX!
import javafx.application.Application
import javafx.scene.Scene
import javafx.scene.control.Label
import javafx.scene.layout.StackPane
import javafx.stage.Stage
class HelloFX : Application() {
override fun start(stage: Stage) {
// create a text label and add it to the scene
val label = Label("Hello JavaFX")
val scene = Scene(StackPane(label), 320.0, 240.0)
// setup and show the stage (window)
stage.title = "HelloFX"
stage.scene = scene
stage.show()
}
}
objects on the screan is represented as a hierarchy of screan elements.
java.lang.Object - javafx.stage.Window - javafx.stage.Stage
java.lang.Object - javafx.scene.Scene
java.lang.Object - javafx.scene.Node