JavaFX Label class

Introduction

Demonstrate a JavaFX label.



import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

public class Main extends Application {
   public static void main(String[] args) {
      launch(args);//www . ja  va2  s. com
   }
   public void start(Stage myStage) {
      myStage.setTitle("Demonstrate a JavaFX label.");
      FlowPane rootNode = new FlowPane();

      // Create a scene.
      Scene myScene = new Scene(rootNode, 300, 200);

      // Set the scene on the stage.
      myStage.setScene(myScene);

      // Create a label.
      Label myLabel = new Label("This is a JavaFX label");

      // Add the label to the scene graph.
      rootNode.getChildren().add(myLabel);

      // Show the stage and its scene.
      myStage.show();
   }
}



PreviousNext

Related