Im trying to change a ComboBox Font on JavaFx, so I have:
ComboBox cbCategoria = new ComboBox();
Im new in javaFx so some example code would be great :D, Is a Way to do it without CSS? and if not how can i make it with CSS,I havent learned how to use CSS Styling yet :(
I think there is no way to do it without CSS. You can assign the style to that component as in the next sample:
VBox vbox = new VBox(10);
vbox.setAlignment(Pos.CENTER_LEFT);
ComboBox<String> noStyled = new ComboBox<>();
noStyled.getItems().addAll("One", "Two", "Three");
ComboBox<String> styled = new ComboBox<>();
styled.setPrefWidth(150);
styled.getItems().addAll("One", "Two", "Three");
styled.setStyle("-fx-font: 30px \"Serif\";");
vbox.getChildren().addAll(noStyled, styled);
Scene scene = new Scene(vbox);
stage.setScene(scene);
stage.show();
Or you can assign a stylesheet to an application. In both cases I recommend you to go through the tutorial CSS Section in the oracle web site and the reference guide.
Hope it helps.
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