Actually searched everywhere but any answer can't help me, sohere's the problem: I want to add a custom font to my buttons. I already tried to write a css java class and a lot of other solutions, but nothing helped my.
/code deleted/
I'd be so glad if anyone could help me!
Update: I tried this:
package view;
import ...
public class SceneStyle {
ImageView header = new ImageView("/view/images/header.jpg");
ImageView chatImg = new ImageView("/view/images/chat_win.jpg");
//Layout Style
//public String font1 = "Impact";
//public String font2 = "Comic Sans MS";
public static String color1 = "#00adf0";
public static String color2 = "#0076a3";
public void setLabelStyle(Label label) {
label.setStyle("-fx-font-family: Inconsolata:700; -fx-font-size: 25");
Scene scene = new Scene(label);
scene.getStylesheets().add("https://fonts.googleapis.com/css?family=Inconsolata:700");
label.setTextFill(Color.GRAY);
}
public void setLabelStyle2(Label label){
label.setStyle("-fx-font-family: Inconsolata:700; -fx-font-size: 25");
Scene scene = new Scene(label);
scene.getStylesheets().add("https://fonts.googleapis.com/css?family=Inconsolata:700");
label.setTextFill(Color.GRAY);
}
public void setLabelStyle3(Label label){
label.setStyle("-fx-font-family: Inconsolata:700; -fx-font-size: 25");
Scene scene = new Scene(label);
scene.getStylesheets().add("https://fonts.googleapis.com/css?family=Inconsolata:700");
label.setTextFill(Color.RED);
}
public void setButtonStyle(Button button){
button.setStyle("-fx-font-family: Inconsolata:700; -fx-font-size: 30; -fx-font-style: normal");
Scene scene = new Scene(button);
scene.getStylesheets().add("https://fonts.googleapis.com/css?family=Inconsolata:700");
button.setTextFill(Color.web(color2));
button.setPrefWidth(190);
}
public void setBorderPaneStyle(BorderPane pane, VBox btnBox, HBox scoreBox){
pane.setTop(header);
pane.setLeft(btnBox);
pane.setRight(chatImg);
pane.setBottom(scoreBox);
pane.getLeft().setStyle("-fx-background-image: url(\"/view/images/border_left.jpg\");");
pane.getBottom().setStyle("-fx-background-image: url(\"/view/images/bottom.jpg\");");
//pane.getCenter().setStyle("-fx-background-image: url(\"/view/images/center.jpg\");");
//TODO: why can't I implement this?
}
public static String getFontColor1(){ return color1; }
public static String getFontColor2(){ return color2; }
Thanks for the detailed answers, but actually I don't want to write a start method which is overwritten. Just want to implemtent the font in my code. And yes now I'm trying with the Google Fonts. Thanks for answering my question.