設定がインスタンス化され、MainControllerで初期化されているコンストラクタのパラメータ "Settings"オブジェクトでMoviesSettingsControllerを呼び出すにはどうすればよいですか? SideMenuControllerでSettingsを渡し、次にMoviesSettingsControllerで設定を渡す必要がありますか?私はこれで失われた小さなビットです。fxmlファイルとフローライブラリを使用してコントローラのパラメータを取得する方法は?
io.datafx.controller.flow.FlowException: io.datafx.controller.FxmlLoadException: java.lang.InstantiationException: maxiRename.controller.MoviesSettingsController
at io.datafx.controller.flow.action.FlowLink.handle(FlowLink.java:72)
at io.datafx.controller.flow.FlowHandler.handle(FlowHandler.java:231)
at io.datafx.controller.flow.FlowHandler.handle(FlowHandler.java:163)
at maxiRename.controller.SideMenuController.lambda$0(SideMenuController.java:79)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at com.jfoenix.controls.JFXListCell.lambda$updateItem$157(JFXListCell.java:295)
at com.jfoenix.controls.JFXListCell.access$lambda$9(JFXListCell.java)
at com.jfoenix.controls.JFXListCell$$Lambda$10.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: io.datafx.controller.FxmlLoadException: java.lang.InstantiationException: maxiRename.controller.MoviesSettingsController
at io.datafx.controller.ViewFactory.createByController(ViewFactory.java:180)
at io.datafx.controller.flow.action.FlowLink.handle(FlowLink.java:69)
... 85 more
Caused by: java.lang.InstantiationException: maxiRename.controller.MoviesSettingsController
at java.lang.Class.newInstance(Class.java:427)
at io.datafx.controller.ViewFactory.createByController(ViewFactory.java:148)
... 86 more
Caused by: java.lang.NoSuchMethodException: maxiRename.controller.MoviesSettingsController.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 87 more
MainApp.java:
public void start(Stage stage) throws Exception {
Flow flow = new Flow(MainController.class);
DefaultFlowContainer container = new DefaultFlowContainer();
flowContext = new ViewFlowContext();
flowContext.register("Stage", stage);
flow.createHandler(flowContext).start(container);
JFXDecorator decorator = new JFXDecorator(stage, container.getView());
decorator.setCustomMaximize(true);
Scene scene = new Scene(decorator, 770, 690);
scene.getStylesheets().add(MainMaxiFilm.class.getResource("/resources/css/jfoenix-main-demo.css").toExternalForm());
stage.setWidth(770);
stage.setHeight(690);
stage.setResizable(false);
stage.setScene(scene);
stage.show();
}
MainController.java:
@FXMLController(value = "/resources/fxml/Main.fxml", title = "Material Design Example")
public class MainController implements Initializable{
@FXMLViewFlowContext
private ViewFlowContext context;
@FXML
private StackPane root;
@FXML
private BorderPane mainBorderPane;
@FXML
private VBox mainVBoxTop;
@FXML
private JFXToolbar mainToolbarTop;
@FXML
private JFXHamburger mainHamburgerTop;
@FXML
private JFXDrawer mainDrawer;
private FlowHandler flowHandler;
private FlowHandler sideMenuFlowHandler;
public void initialize(URL url, ResourceBundle rb) {
try {
HamburgerBackArrowBasicTransition transition = new HamburgerBackArrowBasicTransition(mainHamburgerTop);
transition.setRate(-1);
mainDrawer.setOnDrawerOpening((e) -> {
transition.setRate(1);
transition.play();
});
mainDrawer.setOnDrawerClosing((e) -> {
transition.setRate(-1);
transition.play();
});
mainHamburgerTop.setOnMouseClicked((e)->{
if (mainDrawer. isShown() || mainDrawer.isShowing()) {
mainDrawer.close();
}
else
mainDrawer.open();
});
// create the inner flow and content
context = new ViewFlowContext();
// set the default controller
Flow innerFlow = new Flow(HomeController.class);
flowHandler = innerFlow.createHandler(context);
context.register("ContentFlowHandler", flowHandler);
context.register("ContentFlow", innerFlow);
mainDrawer.setContent(flowHandler.start());
context.register("ContentPane", mainDrawer.getContent().get(0));
// side controller will add links to the content flow
Flow sideMenuFlow = new Flow(SideMenuController.class);
sideMenuFlowHandler = sideMenuFlow.createHandler(context);
mainDrawer.setSidePane(sideMenuFlowHandler.start());
} catch (FlowException ex) {
Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
あなたは一瞬で
後にすべての私のファイルを見つけるだろう、私はこのエラーを取得します
SideMenuController.java:
@FXMLController(value = "/resources/fxml/SideMenu.fxml", title = "Material Design Example")
public class SideMenuController {
@FXML
private StackPane root;
@FXML
private VBox listViewDrawer;
@FXML
private ImageView imageTopDrawer;
@FXML
private JFXListView<?> sideList;
@FXML
private Label home;
@FXML
private JFXListView<?> subList;
@FXML
private Label musics;
@FXML
private Label movies;
@FXML
private Label series;
@FXML
private Label help;
@FXML
private Label exit;
@FXMLViewFlowContext
private ViewFlowContext context;
@PostConstruct
public void init() throws FlowException, VetoException {
sideList.propagateMouseEventsToParent();
System.out.println(context);
FlowHandler contentFlowHandler = (FlowHandler) context.getRegisteredObject("ContentFlowHandler");
Flow contentFlow = (Flow) context.getRegisteredObject("ContentFlow");
System.out.println(subList.getItems().get(0));
bindNodeToController(home, HomeController.class, contentFlow, contentFlowHandler);
bindNodeToController(musics, MusicsSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(movies, MoviesSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(series, SeriesSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(help, HelpController.class, contentFlow, contentFlowHandler);
}
private void bindNodeToController(Node node, Class<?> controllerClass, Flow flow, FlowHandler flowHandler) {
flow.withGlobalLink(node.getId(), controllerClass);
node.setOnMouseClicked((e) -> {
try {
flowHandler.handle(node.getId());
} catch (Exception e1) {
e1.printStackTrace();
}
});
}
}
そしてMoviesSettingsControler.java:私は、コントローラで設定オブジェクトをしたい
@FXMLController(value = "/resources/fxml/MoviesSettings.fxml" , title = "Material Design Example")
public class MoviesSettingsController{
@FXML
private GridPane gridSettingsMovies;
@FXML
private Label labelSettingsMovies;
@FXML
private Label labelFilesNameSettingsMovies;
@FXML
private JFXButton buttonCancelMoviesSettings;
@FXML
private JFXButton buttonOKMoviesSettings;
@FXML
private GridPane gridFilesName;
@FXML
private ToggleGroup groupFilesName;
@FXML
private JFXRadioButton radioButtonFiles5;
@FXML
private JFXRadioButton radioButtonFiles6;
@FXML
private JFXRadioButton radioButtonFiles3;
@FXML
private JFXRadioButton radioButtonFiles2;
@FXML
private JFXRadioButton radioButtonFiles1;
@FXML
private JFXRadioButton radioButtonFiles4;
private Settings settings = new Settings();
public MoviesSettingsController (Settings pSettings)
{
this.settings = pSettings;
}
public Settings getSettings() {
return settings;
}
public void setSettings(Settings settings) {
this.settings = settings;
}
public void saveChange (int pRb, int pPart)
{
this.settings.setMovieName(pRb);
}
@FXML
void saveSettingsMovies(ActionEvent event) {
System.out.println(groupFilesName.getSelectedToggle());
}
。 問題は、この(と思う)(コードSideMenuController.javaから来る)の周りにある:
@PostConstruct
public void init() throws FlowException, VetoException {
sideList.propagateMouseEventsToParent();
System.out.println(context);
FlowHandler contentFlowHandler = (FlowHandler) context.getRegisteredObject("ContentFlowHandler");
Flow contentFlow = (Flow) context.getRegisteredObject("ContentFlow");
System.out.println(subList.getItems().get(0));
bindNodeToController(home, HomeController.class, contentFlow, contentFlowHandler);
bindNodeToController(musics, MusicsSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(movies, MoviesSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(series, SeriesSettingsController.class, contentFlow, contentFlowHandler);
bindNodeToController(help, HelpController.class, contentFlow, contentFlowHandler);
}
private void bindNodeToController(Node node, Class<?> controllerClass, Flow flow, FlowHandler flowHandler) {
flow.withGlobalLink(node.getId(), controllerClass);
node.setOnMouseClicked((e) -> {
try {
flowHandler.handle(node.getId());
} catch (Exception e1) {
e1.printStackTrace();
}
});
}
はどうもありがとうございました:)
チップのおかげで! – Eliott