Source of LabelDemo.java


  1: import javafx.application.Application;
  2: import javafx.scene.Scene;
  3: import javafx.stage.Stage;
  4: import javafx.scene.text.Font;
  5: import javafx.scene.layout.VBox;
  6: import javafx.scene.control.Label;
  7: 
  8: public class LabelDemo extends Application
  9: {
 10:    public static void main(String[] args)
 11:    {
 12:       launch(args);
 13:    }
 14: 
 15:    @Override
 16:    public void start(Stage primaryStage) throws Exception
 17:    {
 18:           VBox root = new VBox();
 19:         Label label1, label2;
 20:           label1 = new Label("Hello");
 21:           label1.setFont(Font.font("Times New Roman", 24));
 22:           label2 = new Label("Out there!");
 23:           label2.setFont(Font.font("Courier New", 36));
 24:           root.getChildren().add(label1);
 25:           root.getChildren().add(label2);
 26: 
 27:              Scene scene = new Scene(root, 300, 100);
 28:         primaryStage.setTitle("Label Demo");
 29:         primaryStage.setScene(scene);
 30:         primaryStage.show();
 31:    }
 32: }