javafxラベルに問題があります。下のフォントコンストラクタでどんなフォントを入力しても、IntelliJプロジェクトをコンパイルして実行しても、表示されるフォントは変更されません。ここでフォント名が変更されないのはなぜですか? (Java FX)
mainLabel.setFont(new Font("Gotham",18));
は、これまでのところ、私のJavaFXのプログラムです:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import javafx.scene.text.Font;
public class JavaFXMainWindow extends Application {
public static void main(String args[]) {
launch(args);
}
public void init() {
}
//Program starts here
public void start(Stage mainStage) {
//Setting the stage
mainStage.setTitle("Ping Tool");
mainStage.setResizable(false);
mainStage.setFullScreen(false);
//Creating the root node for all other nodes
FlowPane rootNode = new FlowPane();
//Setting the main scene, adding the root node to it and passing dimensions
Scene mainScene = new Scene(rootNode, 1000, 800);
//placing the scene on the stage
mainStage.setScene(mainScene);
//Setting a label (no matter what argument I pass to the font it still
//shows the same font. The size argument works fine though)
Label mainLabel = new Label("Please enter IP addresses below:");
mainLabel.setFont(new Font("Gotham",18));
//Adding the node to the tree
rootNode.getChildren().addAll(mainLabel);
//making the Stage visible
mainStage.show();
}
public void stop() {
}
}
フォントが指定された名前でシステムに存在しない(または、JVMがフォントを読み込めるようにインストールされていない)可能性があります。 'Font.getFontNames()'を使って全ての利用可能なフォント名を一覧表示することができます。私のシステムでは、 'Gotham'はリストされていませんでした – MadProgrammer