RingJavafor Ring

JavaFX

JavaFX is not in the JDK.

JavaFX is not in the JDK. jJavaFX(cVersion) downloads the jars of this computer's platform (javafx-base, javafx-graphics, javafx-controls; jJavaFXModules adds fxml, media, web, swing), starts the toolkit and puts the program in GUI mode, as jGui() does for Swing (see Windows and events): the calls of Ring run on the JavaFX application thread and the event functions run on the Ring thread in jMainLoop().

Ring
load "java.ring"
jJavaFX("21.0.2")
jJavaFXClasses("21.0.2")                 # the Ring classes of javafx.* (made once)
using {
	"javafx.stage"
	"javafx.scene"
	"javafx.scene.control"
	"javafx.scene.layout"
}

oButton = new Button("Click me")
oButton.setOnAction("onClick")
oStage = new Stage
oStage.setScene((new Scene).@New([ new StackPane(oButton) , 320 , 160 ]))
oStage.show()
jMainLoop()

func onClick aArgs
	oButton.setText("Clicked")
A JavaFX window made from Ring
05_javafx_hello.ring after three clicks
FunctionMeaning
jJavaFX(cVersion)download, class path, toolkit, GUI mode
jJavaFXClasses(cVersion)the Ring classes of the javafx.* packages
jJavaFXModules(aModules)the modules to download (before jJavaFX)
jFXRunLater(cFunction)Platform.runLater with a Ring function
jFXMessage(cText)an Alert message

jMainLoop(), jStopLoop() and jAutoClose() work for JavaFX windows too. JavaFX runs from the class path (the "unsupported configuration" warning of the JavaFX launcher does not apply because the toolkit is started with Platform.startup). Platform.setImplicitExit(false) is set so that closing the last window does not stop the toolkit.

Custom controls and Application subclasses need Java code (Ring cannot subclass a Java class); everything that is built from the existing classes and listeners works.

Notes#

RingJava - use Java classes and methods from Ring programs.