JavaFX How to - import javafx.application.Application;








Question

We would like to know how to import javafx.application.Application;.

Answer

import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
//  w  ww. j  av  a2 s.  com
public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250);

    Text text1 = new Text();
    text1.setText("Hello World!");
    text1.setX(50);
    text1.setY(50);
    text1.setFill(Color.RED);

    g.getChildren().add(text1);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
}