vickal93 |
JavaFX custom fonts
Meine Frage:
Ich will eine Schriftart zu meinem Programm hinzufügen, die nicht zwangsweise auf jedem Rechner drauf ist. Ich habe schon versuch eine CSS zuschreiben oder es direkt im COde zu implementieren, bin dennoch gescheitert.
Css:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
|
@font-face {
font-family: 'Fleftex_M';
src: url('Fleftex_M.ttf');
}
.background {
-fx-background-color: #1d1d1d;
}
.button {
-fx-padding: 5 22 5 22;
-fx-border-color: #e2e2e2;
-fx-border-width: 2;
-fx-background-radius: 0;
-fx-background-color: #1d1d1d;
-fx-font-family: "Fleftex_M";
-fx-font-size: 11pt;
-fx-text-fill: #d8d8d8;
-fx-background-insets: 0 0 0 0, 0, 1, 2;
}
|
|
und das Packet "view":
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
|
import ...
public class StartScene extends SceneStyle{
private Scene scene;
Button playBtn, chatBtn, highscoreBtn, optionsBtn, quitBtn;
VBox btnBox;
BorderPane borderPane;
HBox scoreBox;
public StartScene(){
scene.getStylesheets().add("/view/resources/styles.css");
playBtn = new Button("PLAY");
chatBtn = new Button("CHAT");
highscoreBtn = new Button("HIGHSCORE");
optionsBtn = new Button("OPTIONS");
quitBtn = new Button("QUIT");
//Buttonsstyling by setting an ID to the CSS file
playBtn.setId("button");
chatBtn.setId("button");
highscoreBtn.setId("button");
optionsBtn.setId("button");
quitBtn.setId("button");
//BORDER LEFT
btnBox = new VBox(playBtn, chatBtn, highscoreBtn, optionsBtn, quitBtn);
btnBox.setSpacing(10);
btnBox.setPadding(new Insets(20));
btnBox.setPrefSize(250, 400);
//BORDER BOTTOM
scoreBox = new HBox();
scoreBox.setPrefSize(200, 1100);
scoreBox.setPadding(new Insets(20, 0, 0, 250));
borderPane = new BorderPane();
setBorderPaneStyle(borderPane, btnBox, scoreBox);
this.scene = new Scene(borderPane, 1100, 650);
}
//(some other code)
}
|
|
Meine Ideen:
Ich wäre sehr dankbar über jede Hilfe! |