I am making a project in javafx. As part of it I created a warning box. Its text font size is too small. The code of the warning box is :
Stage dialogStage = new Stage();
dialogStage.initStyle(StageStyle.UTILITY);
dialogStage.setScene(new Scene(VBoxBuilder.create().
children(new Text("Username or Password Error...!\n"
+ "Please Enter Correct Details...")).
alignment(Pos.CENTER).padding(new Insets(15,15,15,15)).build()));
dialogStage.show();
How can I change or increase the text font size ?
Making Text Bold or Italic To make the text look bold, use the FontWeight constant of the font method as shown in Example 8. t. setFont(Font. font("Verdana", FontWeight.
If you are designing your Javafx application using SceneBuilder then use -fx-text-fill (if not available as option then write it in style input box) as style and give the color you want,it will change the text color of your Textfield .
StackPane lays out its children in a back-to-front stack. The z-order of the children is defined by the order of the children list with the 0th child being the bottom and last child on top. If a border and/or padding have been set, the children will be layed out within those insets.
Text class determines whether each line of the text should have a straight line below it. You can set the value to this property using the setUnderline() method. It accepts a boolean value. You can have a line below the text (node) by passing true as an argument to this method.
I just did this:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.VBoxBuilder;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TextApp extends Application
{
@Override
public void start(Stage primaryStage)
{
final Text caption = new Text("Username or Password Error...!\n"
+ "Please Enter Correct Details...");
caption.setFill(Color.BLACK);
caption.setStyle("-fx-font: 24 arial;");
Stage dialogStage = new Stage();
dialogStage.initStyle(StageStyle.UTILITY);
dialogStage.setScene(new Scene(VBoxBuilder.create().children(caption).alignment(Pos.CENTER)
.padding(new Insets(15, 15, 15, 15)).build()));
dialogStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With