Reputation: 1813
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 ?
Upvotes: 10
Views: 60690
Reputation: 525
You can use CSS to do that.
Check if code here is useful: https://gist.github.com/jewelsea/1887631
Something like this:
.modal-dialog {
-fx-padding: 20;
-fx-spacing: 10;
-fx-alignment: center;
-fx-font-size: 20;
}
and then apply it.
Upvotes: 7
Reputation: 1954
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);
}
}
Upvotes: 13