I am trying to resize the font of my labels whenever i resize my window
my code is
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class Questions extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
GridPane info = new GridPane();
BorderPane display = new BorderPane();
Font font = new Font("monospace",20);
Label lblName = new Label("Name");
Label lblGender = new Label("Gender");
lblName.setFont(font);
lblGender.setFont(font);
info.add(lblName, 0, 0);
info.add(lblGender, 0, 1);
display.setCenter(info);
Scene scene = new Scene(display);
primaryStage.setTitle("Random NPC Generator");
primaryStage.setScene(scene);
primaryStage.setHeight(655);
primaryStage.setWidth(555);
primaryStage.show();
}
}
i have googled forever it seems like and cannot find the answer, so again, Any idea how to resize the labels whenever i resize the main window? Thanks in advance! Edit: I am looking for a way to do it in JavaFX not awf