Friday, May 4, 2012

JavaFX TextBuilder with properties



package javafx_text;
import javafx.application.Application;
import javafx.geometry.VPos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextBuilder;
import javafx.stage.Stage;
/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFX_Text 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");
 Group root = new Group();
 
 String stringHello = "Hello, Java Buddy! \n"
 + "http://java-buddy.blogspot.com/";
 
 Text textHello = TextBuilder.create()
 .text(stringHello)
 .layoutX(50)
 .textOrigin(VPos.TOP)
 .textAlignment(TextAlignment.RIGHT)
 .fill(Color.BLUE)
 .font(Font.font("SansSerif", FontPosture.ITALIC, 28))
 .build();
 
 root.getChildren().add(textHello);
 
 primaryStage.setScene(new Scene(root, 500, 400));
 primaryStage.show();
 }
}


No comments:

Post a Comment

[フレーム]

Subscribe to: Post Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /