相关疑难解决方法(0)

为什么 JavaFX 应用程序和场景构建器显示乱码?

这是我的场景构建器的样子:

在此处输入图片说明

这是图形用户界面:

在此处输入图片说明

独立的场景构建器:

在此处输入图片说明

我只是从 Java SDK 演示中运行以下源代码:

package sample;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        Button btn = new Button();
        btn.setText("Say 'Hello World'!");
        StackPane root_ctn = new StackPane();
        root_ctn.getChildren().add(btn);
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                System.out.println("Hello World!");
            }
        });
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root_ctn, 300, 275));
        primaryStage.show(); …
Run Code Online (Sandbox Code Playgroud)

java javafx intellij-idea fxml scenebuilder

6
推荐指数
1
解决办法
1320
查看次数

标签 统计

fxml ×1

intellij-idea ×1

java ×1

javafx ×1

scenebuilder ×1