JFXApp

@deprecated("`JFXApp` depends on `DelayedInit` that is deprecated since Scala 2.11.0 and no longer works in Scala 3. Use `JFXApp3` instead.", since = "16.0.0-R23") trait JFXApp extends DelayedInit

ScalaFX applications can extend JFXApp to create properly initialized JavaFX applications.

ScalaFX applications can extend JFXApp to create properly initialized JavaFX applications.

On the back end JFXApp first calls javafx.application.Application.launch then executes body of its constructor when javafx.application.Application.start(primaryStage:Stage) is called. Here is an example use:

 object SimpleScalaFXApp extends JFXApp {
    stage = new PrimaryStage {
      title = "Simple ScalaFX App"
      scene = new Scene {
        root = new StackPane {
          padding = Insets(20)
          content = new Rectangle {
            width = 200
            height = 200
            fill = Color.DEEPSKYBLUE
          }
        }
      }
    }
 }
Companion
object
Deprecated
[Since version 16.0.0-R23]

JFXApp depends on DelayedInit that is deprecated since Scala 2.11.0 and no longer works in Scala 3. Use JFXApp3 instead.

trait DelayedInit
class Object
trait Matchable
class Any

Value members

Concrete methods

def delayedInit(x: => Unit): Unit

Add class/object construction/initialization code to the code execution buffer.

Add class/object construction/initialization code to the code execution buffer.

This function is called multiple times (by the Scala compiler) with the initialization/construction code of each class and object (but not trait!) that extends JFXApp. This code is buffered until it can be executed in main().

Value Params
x

Class/object construction code to be buffered for delayed execution.

Note

You are strongly advised not to override this function.

def main(args: Array[String]): Unit

Perform app-related initialization, and execute initialization/construction code for all classes and objects that extend this trait.

Perform app-related initialization, and execute initialization/construction code for all classes and objects that extend this trait.

Value Params
args

Command line arguments.

Note

You are strongly advised not to override this function.

def stopApp(): Unit

This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.

This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.

It is called from javafx.Application.stop method. The implementation of this method provided by the JFXApp class does nothing.

NOTE: This method is called on the JavaFX Application Thread, the same as javafx.Application.stop method.

Concrete fields

JFXApp stage must be an instance of scalafx.application.JFXApp.PrimaryStage to ensure that it actually is a proper wrapper for the primary stage supplied by JavaFX.

JFXApp stage must be an instance of scalafx.application.JFXApp.PrimaryStage to ensure that it actually is a proper wrapper for the primary stage supplied by JavaFX.