Text with CHOCOLATE color and Font.SERIF : Text « JavaFX « Java






Text with CHOCOLATE color and Font.SERIF

 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }
    
    @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.CHOCOLATE);
        text1.setFont(Font.font(java.awt.Font.SERIF, 25));
        root.getChildren().add(text1);
        
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

   
  








Related examples in the same category

1.Create Static Text control and set color
2.Rotate a Text
3.Text with DropShadow
4.Line breaking for Text
5.Reflection effect on text
6.Set fill and font for Text
7.Binding Stage x, y, width, height to Text control
8.Text wrapping width
9.Set Text Font
10.Text class defines a node that displays a text
11.Reflected Text
12.Text Effect show off
13.Paragraphs are separated by '\n' and the text is wrapped on paragraph boundaries.