Tuesday, January 31, 2012

JavaFX exercise: display text on Scene

display text on Scene
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");

Text text = new Text(50, 50, "Hello Java-Buddy");

StackPane root = new StackPane();
root.getChildren().add(text);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}

No comments:

Post a Comment

Post a Comment