Example usage for javafx.scene.text Text setFont

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

Introduction

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

Prototype

public final void setFont(Font value) 

Source Link

Usage

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  . jav  a2  s. c o  m*/

    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();
}

From source file:Main.java

private FlowPane createTopBanner() {
    FlowPane topBanner = new FlowPane();
    topBanner.setPrefHeight(40);//from   ww w.  j a v a 2  s  .  c o  m

    Font serif = Font.font("Dialog", 30);

    Text contactText = new Text("Contacts");
    contactText.setFill(Color.BLACK);
    contactText.setFont(serif);

    topBanner.getChildren().addAll(contactText);

    return topBanner;
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX Welcome");
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);//  ww  w .  ja v  a2s. c o  m
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("Welcome");
    scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 2, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

    TextField userTextField = new TextField();
    grid.add(userTextField, 1, 1);

    Label pw = new Label("Password:");
    grid.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    grid.add(pwBox, 1, 2);

    Button btn = new Button("Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 1, 6);

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Sign in button pressed");
        }
    });

    Scene scene = new Scene(grid, 300, 275);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:de.pixida.logtest.designer.automaton.ConfigFrame.java

ConfigFrame(final String aTitle) {
    Validate.notNull(aTitle);/*ww w . ja  v a 2 s  .c  o  m*/
    this.title = aTitle;

    this.setHbarPolicy(ScrollBarPolicy.NEVER);
    this.setFitToWidth(true);

    final int insets = 10;
    this.vbox.setPadding(new Insets(insets));
    final int spacing = 8;
    this.vbox.setSpacing(spacing);

    final Text titleText = new Text(this.title);
    final int titleFontSize = 14;
    titleText.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, titleFontSize));
    this.vbox.getChildren().add(titleText);

    this.setContent(this.vbox);

    final int minWidth = 200;
    this.setMinWidth(minWidth);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//from w w  w.ja  v a  2s.  c  o m
    stage.setTitle("Sample");

    Text t = new Text(10, 50, "This is a test");
    t.setWrappingWidth(200);
    t.setText("First row Second row Second row Second row Second row Second row ");
    t.setFont(new Font(20));

    root.getChildren().add(t);

    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();

    Text t = new Text();
    t.setX(10.0);//from   ww w  .  j a  v  a  2 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);/*w w w .ja va  2 s  .  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) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);//from  w  w w .  ja v a 2 s  .c  om

    Group g = new Group();
    PerspectiveTransform pt = new PerspectiveTransform();
    pt.setUlx(10.0);
    pt.setUly(10.0);
    pt.setUrx(310.0);
    pt.setUry(40.0);
    pt.setLrx(310.0);
    pt.setLry(60.0);
    pt.setLlx(10.0);
    pt.setLly(90.0);

    g.setEffect(pt);
    g.setCache(true);

    Rectangle r = new Rectangle();
    r.setX(10.0);
    r.setY(10.0);
    r.setWidth(280.0);
    r.setHeight(80.0);
    r.setFill(Color.BLUE);

    Text t = new Text();
    t.setX(20.0);
    t.setY(65.0);
    t.setText("JavaFX");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));

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

    scene.setRoot(g);
    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);

    Text t = new Text();
    t.setX(10.0);/* ww w.  j ava 2s .  c  om*/
    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:net.gazeplay.commons.utils.License.java

private Text licence(double width, double height) {
    Text text = new Text();

    text.setX(width * 0.1);//ww w. j  a  v  a2 s.  co m
    text.setY(height * 0.1);
    text.setFont(new Font(20));

    text.setFill(new Color(1, 1, 1, 1));

    String content = loadLicenseContentAsString();
    text.setText(content);

    return text;

}