这是我的第一堂课,它有一个字符串“CatID”:
public void handleButtonlActionPickItem(ActionEvent event, String CatID) {
FxmlLoader object = new FxmlLoader();
Pane view = object.getPageParams("PickItem", "cate1");
mainPane.getChildren().setAll(view);
}
这是我的第二个控制器,只加载一个窗格到全局fxml文件
public Pane getPageParams(String fileName, String ID) {
try {
URL fileUrl = App.class.getResource("Mypath" + fileName + ".fxml");
if (fileUrl == null) {
throw new java.io.FileNotFoundException("FXML file can't be found");
}
view = new FXMLLoader().load(fileUrl);
} catch (Exception e) {
System.out.println("No page " + fileName + " please check Fxm1Loader.");
}
return view;
}
这是下一个 fxml 文件的控制器:
public class PickItemController implements Initializable {
@FXML
private GridPane grid;
@FXML
private AnchorPane mainPane;
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println(CatID);
}
}
如何在 PickItemController 类中获取 CatID 并在 initialize() 中打印它
我试图在类之间发送值,但我得到它为空