JFXApp3

scalafx.application.JFXApp3
See theJFXApp3 companion object
trait JFXApp3

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

On the back end JFXApp3 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:

 import scalafx.application.JFXApp3
 import scalafx.application.JFXApp3.PrimaryStage
 import scalafx.geometry.Insets
 import scalafx.scene.Scene
 import scalafx.scene.layout.HBox
 import scalafx.scene.paint.Color._
 import scalafx.scene.paint._
 import scalafx.scene.text.Text

 object JFXApp3Demo extends JFXApp3 {
   override def start(): Unit = {
     stage = new PrimaryStage {
       title = "ScalaFX Hello World!"
       scene = new Scene {
         fill = Color.rgb(38, 38, 38)
         content = new HBox {
           padding = Insets(50, 80, 50, 80)
           children = Seq(
             new Text {
               text = "Hello World!"
               style = "-fx-font: normal bold 100pt sans-serif"
               fill = new LinearGradient(endX = 0, stops = Stops(Red, DarkRed))
             }
           )
         }
       }
     }
   }
 }

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def start(): Unit

The main application method. Executed on JavaFX Application thread.

The main application method. Executed on JavaFX Application thread.

Attributes

Concrete methods

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 parameters

args

Command line arguments.

Attributes

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 JFXApp3 class does nothing.

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

Attributes

Concrete fields

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

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

Attributes