more examples en
    
 

EIN ERSTES JavaFX-PROGRAMM

API

javafx.application.Application
javafx.scene.Scene
javafx.stage.Stage
javafx.scene.control.Label

 

A JavaFX application must extend the abstract class javafx.application.Application. Application provides the three life-cycle methods init(), start(), and stop(). At least the abstract method start(Stage stage) must be implemented.
javafx.stage.Stage is more or less equivalent to a javax.swing.JFrame. A stage can have one or more javafx.scene.Scene objects, but it can only show one Scene object at a time.

 

 1 package at.krux.javafx;

 2 import javafx.application.Application;
 3 import javafx.scene.Scene;
 4 import javafx.scene.control.Label;
 5 import javafx.stage.Stage;

 6 public class FxSceneWithLabel extends Application {

 7   public static void main(String[] args) { launch(args); }

 8   public void start(Stage stage) {
 9     Label label = new Label("Truth is stranger than fiction.");
10     Scene scene = new Scene(label, 200, 200);
11     stage.setScene(scene);
12     stage.show();
13   }
14 }