Example usage for javafx.scene.text Text Text

List of usage examples for javafx.scene.text Text Text

Introduction

In this page you can find the example usage for javafx.scene.text Text Text.

Prototype

public Text() 

Source Link

Document

Creates an empty instance of Text.

Usage

From source file:Main.java

@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);//from  ww w.  j  a  va2  s .c  o m
    text1.setY(50);
    text1.setFill(Color.RED);

    g.getChildren().add(text1);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Text t = new Text();
    t.setX(10.0);/* w  w  w  .  j a  v a  2s.  c  o  m*/
    t.setY(50.0);
    t.setCache(true);
    t.setText("Reflections on JavaFX...");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 30));

    Reflection r = new Reflection();
    r.setFraction(0.7);

    t.setEffect(r);

    root.getChildren().add(t);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Group g = new Group();

    Text t = new Text();
    t.setX(10.0);/* w  w w  . j a  va2 s  . co m*/
    t.setY(40.0);
    t.setCache(true);
    t.setText("Blurry Text");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));

    t.setEffect(new GaussianBlur());

    g.getChildren().add(t);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);//from w  w w .  j  a  v a 2s .co m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());
    VBox root = new VBox();

    InnerShadow is = new InnerShadow();
    is.setOffsetX(4.0);
    is.setOffsetY(4.0);

    Text t = new Text();
    t.setEffect(is);
    t.setX(20);
    t.setY(100);
    t.setText("java2s.com");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 80));

    root.getChildren().addAll(t);

    scene.setRoot(root);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);// w w w .  j a  v a  2  s  .  co m

    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("JavaFX!");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    box.getChildren().add(t);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Group g = new Group();

    DropShadow ds = new DropShadow();
    ds.setOffsetY(3.0);/*from  www.  j  a v  a  2s .  com*/
    ds.setColor(Color.color(0.4, 0.4, 0.4));

    Text t = new Text();
    t.setEffect(ds);
    t.setCache(true);
    t.setX(10.0);
    t.setY(70.0);
    t.setFill(Color.RED);
    t.setText("JavaFX drop shadow...");
    t.setFont(Font.font(null, FontWeight.BOLD, 32));
    g.getChildren().add(t);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

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

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

    Rectangle r = new Rectangle();
    r.setX(10);//from  ww  w .  j a  va  2  s. co m
    r.setY(10);
    r.setWidth(160);
    r.setHeight(80);
    r.setFill(Color.DARKBLUE);

    Text t = new Text();
    t.setText("Bloom!");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));
    t.setX(25);
    t.setY(65);

    g.setCache(true);
    g.setEffect(new Bloom());
    g.getChildren().add(r);
    g.getChildren().add(t);

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

From source file:Main.java

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

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    Rectangle r = new Rectangle();
    r.setX(10);/*from   w ww . j  a  va 2s .c  o  m*/
    r.setY(10);
    r.setWidth(160);
    r.setHeight(80);
    r.setFill(Color.DARKBLUE);

    Text t = new Text();
    t.setText("Bloom!");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));
    t.setX(25);
    t.setY(65);

    g.setCache(true);
    g.setEffect(new Bloom());
    g.getChildren().add(r);
    g.getChildren().add(t);

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

From source file:de.micromata.mgc.javafx.FXGuiUtils.java

/**
 * Computes the required height of a text for a given font and a wrapping width. Wrapping width defines when a text
 * needs to be wrapped if its {@link Label#wrapTextProperty()} is true.
 * //  w  w w.  j  ava  2  s  .co  m
 * @param font font of the label.
 * @param text text to render.
 * @param wrappingWidth wrapping width.
 * @return height.
 */
public static double computeTextHeight(Font font, String text, double wrappingWidth) {
    final Text helper = new Text();
    helper.setText(text);
    helper.setFont(font);

    helper.setWrappingWidth((int) wrappingWidth);
    return helper.getLayoutBounds().getHeight();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group g = new Group();
    final Scene scene = new Scene(g, 300, 250);
    scene.setFill(null);//from   w w  w  .  j a va  2s  .  c om

    Light.Spot light = new Light.Spot();
    light.setX(0);
    light.setY(100);
    light.setZ(50);
    light.setPointsAtX(400);
    light.setPointsAtY(0);
    light.setPointsAtZ(0);
    light.setSpecularExponent(2);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("Spot");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    g.getChildren().add(r);
    g.getChildren().add(t);

    r.setWidth(t.getLayoutBounds().getWidth() + 30);
    r.setHeight(t.getLayoutBounds().getHeight() + 20);

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