我只是下载了 JavaFX 并进行了设置,我没有做任何其他事情。我运行了示例代码,尽管所有内容都已编译,但还是弹出了警告。我正在使用 IntelliJ。
这是在 Main.java 中:
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
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"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
这是在sample.fxml中:
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>
Run Code Online (Sandbox Code Playgroud)
运行时,一切都会编译,会弹出窗口,但我收到标题中所述的警告。
我以前从未使用过 JavaFX,所以我不确定在哪里可以找到这个模块。