Example usage for javafx.scene.text Font Font

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

Introduction

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

Prototype

public Font(@NamedArg("name") String name, @NamedArg("size") double size) 

Source Link

Document

Constructs a font using the specified full face name and size

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);//from   ww w.  j  ava  2  s  .  c om

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(2);
    grid.setHgap(5);

    scene.setRoot(grid);

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    stage.show();
}

From source file:Main.java

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

    final Circle circ = new Circle(40, 40, 30);
    final Group root = new Group(circ);

    final Scene scene = new Scene(root, 800, 400, Color.BEIGE);

    final Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.DARKBLUE);
    text1.setFont(Font.font(java.awt.Font.SERIF, 25));
    final Reflection reflection = new Reflection();
    reflection.setFraction(1.0);//  ww  w .java2  s  .  c o  m
    text1.setEffect(reflection);

    root.getChildren().add(text1);

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

From source file:Main.java

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

    final Circle circ = new Circle(40, 40, 30);
    final Group root = new Group(circ);

    final Scene scene = new Scene(root, 800, 400, Color.BEIGE);

    final Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.DARKBLUE);
    text1.setFont(Font.font(java.awt.Font.SERIF, 25));
    final Effect glow = new Glow(1.0);
    text1.setEffect(glow);//  w  ww . ja  v a  2  s. com
    root.getChildren().add(text1);

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

From source file:Main.java

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

    final Circle circ = new Circle(40, 40, 30);
    final Group root = new Group(circ);

    final Scene scene = new Scene(root, 800, 400, Color.BEIGE);

    final Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.DARKBLUE);
    text1.setFont(Font.font(java.awt.Font.SERIF, 25));
    final Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0);/*  w  ww .ja va2s.co  m*/
    final Lighting lighting = new Lighting();
    lighting.setLight(light);
    lighting.setSurfaceScale(9.0);
    text1.setEffect(lighting);

    root.getChildren().add(text1);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Tooltip Sample");
    stage.setWidth(300);/*from w  ww  . j av a  2  s.c o m*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox("checkBox");
    final Tooltip tooltip = new Tooltip("$ tooltip");
    tooltip.setFont(new Font("Arial", 16));
    cb.setTooltip(tooltip);

    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Tooltip Sample");
    stage.setWidth(300);/*ww w  . j  av a  2  s  . co  m*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox("checkBox");
    final Tooltip tooltip = new Tooltip("$ tooltip");
    tooltip.setFont(new Font("Arial", 16));
    cb.setTooltip(tooltip);
    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });

    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    TextField fName = new TextField();
    TextField lName = new TextField();
    TextField salary = new TextField();

    Button closeBtn = new Button("Close");
    closeBtn.setOnAction(e -> Platform.exit());

    fName.getProperties().put("microHelpText", "Enter the first name");
    lName.getProperties().put("microHelpText", "Enter the last name");
    salary.getProperties().put("microHelpText", "Enter a salary greater than $2000.00.");

    // The help text node is unmanaged
    helpText.setManaged(false);/*from   w  w  w. j  a  va  2s .  c  o m*/
    helpText.setTextOrigin(VPos.TOP);
    helpText.setFill(Color.RED);
    helpText.setFont(Font.font(null, 9));
    helpText.setMouseTransparent(true);

    // Add all nodes to a GridPane
    GridPane root = new GridPane();

    root.add(new Label("First Name:"), 1, 1);
    root.add(fName, 2, 1);
    root.add(new Label("Last Name:"), 1, 2);
    root.add(lName, 2, 2);

    root.add(new Label("Salary:"), 1, 3);
    root.add(salary, 2, 3);
    root.add(closeBtn, 3, 3);
    root.add(helpText, 4, 3);

    Scene scene = new Scene(root, 300, 100);

    // Add a change listener to the scene, so we know when
    // the focus owner changes and display the micro help   
    scene.focusOwnerProperty().addListener((ObservableValue<? extends Node> value, Node oldNode,
            Node newNode) -> focusChanged(value, oldNode, newNode));
    stage.setScene(scene);
    stage.setTitle("Showing Micro Help");
    stage.show();
}

From source file:Main.java

private FlowPane createTopBanner() {
    FlowPane topBanner = new FlowPane();
    topBanner.setPrefHeight(40);//from   w  w w.ja  v a 2s.  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 stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Table View Sample");
    stage.setWidth(300);//from w  ww.j a v a 2  s .c  om
    stage.setHeight(500);

    final Label label = new Label("Student IDs");
    label.setFont(new Font("Arial", 20));

    TableColumn<Map, String> firstDataColumn = new TableColumn<>("Class A");
    TableColumn<Map, String> secondDataColumn = new TableColumn<>("Class B");

    firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey));
    firstDataColumn.setMinWidth(130);
    secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey));
    secondDataColumn.setMinWidth(130);

    TableView tableView = new TableView<>(generateDataInMap());

    tableView.setEditable(true);
    tableView.getSelectionModel().setCellSelectionEnabled(true);
    tableView.getColumns().setAll(firstDataColumn, secondDataColumn);
    Callback<TableColumn<Map, String>, TableCell<Map, String>> cellFactoryForMap = (
            TableColumn<Map, String> p) -> new TextFieldTableCell(new StringConverter() {
                @Override
                public String toString(Object t) {
                    return t.toString();
                }

                @Override
                public Object fromString(String string) {
                    return string;
                }
            });
    firstDataColumn.setCellFactory(cellFactoryForMap);
    secondDataColumn.setCellFactory(cellFactoryForMap);

    final VBox vbox = new VBox();

    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, tableView);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    Scene scene = new Scene(box, 200, 200);
    stage.setScene(scene);/*from ww  w .j a va2 s  .  c  om*/
    stage.setTitle("ListViewSample");
    box.getChildren().addAll(list, label);
    VBox.setVgrow(list, Priority.ALWAYS);

    label.setLayoutX(10);
    label.setLayoutY(115);
    label.setFont(Font.font("Verdana", 20));

    list.setItems(data);

    list.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ColorRectCell();
        }
    });

    list.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
        public void changed(ObservableValue<? extends String> ov, String old_val, String new_val) {
            label.setText(new_val);
            label.setTextFill(Color.web(new_val));
        }
    });
    stage.show();
}