如何从 JavaFX 中的另一个包导入布局?

How can I import a layout from another package in JavaFX?

Here is the code:

            package application;
            //imports
            import javafx.application.Application;
            import javafx.fxml.FXMLLoader;
            import javafx.scene.Scene;
            import javafx.scene.layout.Pane;
            import javafx.stage.Stage;
            import application.view.*; //i've tried import the package, but i don't know if this is correct



            public class Main extends Application {
                @Override
                public void start(Stage primaryStage) {
                    try {

//here is my issue:

                        **Pane root = FXMLLoader.load(getClass().getResource("application.view.Lay.fxml"));**

                        Scene scene = new Scene(root,400,400);
                        primaryStage.setScene(scene);
                        primaryStage.show();
                    } catch(Exception e) {
                        e.printStackTrace();
                    }
                }

            }

I've Tried this, but it doesn't work, what am I doing wrong? Thanks for your time!

尝试

Pane root = FXMLLoader.load(getClass().getResource("/application/view/Lay.fxml"));

如果我们有一个很长的 package 名称,我们必须用正斜杠替换每个点“.”。 就像包含 views/fxml 个文件的包名称是

package org.itsoftsolutions.view; 

我们必须提供这样的路径

FXMLLoader.load(getClass().getResource("/org/itsoftsolutions/view/login.fxml"));