javafx font issue javafx application font issue
问题你好我正在研究javaFX,并尝试运行应用程序来显示数据库MySQL8 + Hibernate中的数据。显示了数据和文件,但是字体表示存在一些问题。您能提供一些建议,如何解决?
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class AppTest extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/views/allAdsView.fxml"));
primaryStage.setTitle("My First App");
primaryStage.setScene(new Scene(root, 1280, 800));
primaryStage.show();
}
}
这是因为使用了字符编码和默认字体“ System”字体,将此添加到您的CSS(或您希望使用的任何其他字体)中,
* {
-fx-font-family: 'Arial';
}