Using Color constant
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
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("Text Fonts");
Group root = new Group();
Scene scene = new Scene(root, 550, 250, Color.WHITE);
Text text = new Text(50, 100, "JavaFX 2.0 from Java2s.com");
Font sanSerif = Font.font("Dialog", 30);
text.setFont(sanSerif);
text.setFill(Color.BLUE);
root.getChildren().add(text);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Related examples in the same category
1. | Create Color from R G B value | | |
2. | Color.DARKBLUE | | |
3. | Create color from web value | | |
4. | Color.TRANSPARENT | | |
5. | Set Rectangle Stroke to Color.BLACK | | |
6. | Names for JavaFX Standard Colors | | |
7. | standard constructor, use 0->1.0 values, explicit alpha of 1.0 | | |
8. | use 0->1.0 values. implicit alpha of 1.0 | | |
9. | use 0->1.0 values, explicit alpha of 1.0 | | |
10. | use 0->255 integers, implict alpha of 1.0 | | |
11. | use 0->255 integers, explict alpha of 1.0 | | |
12. | hue = 270, saturation & value = 1.0. inplict alpha of 1.0 | | |
13. | hue = 270, saturation & value = 1.0, explict alpha of 1.0 | | |
14. | blue as a hex web value, explict alpha | | |
15. | blue as a hex web value, implict alpha | | |
16. | Color as hex web value | | |