Skip to content
Advertisement

Calling a method through from another controller JavaFx

RootLayoutControl.java

JavaScript

MainApp.java

JavaScript

ImageViewController.java

JavaScript

Creating an image gallery, where if I call the method,

handleOpen() in RootLayoutController

It’ll call method,

createImageView() in ImageViewController

To pass the variable file to it, any suggestions on how do I do it?

Advertisement

Answer

First, the createImageView() method needs to be public.

JavaScript

In RootLayoutController you need to create a method to get the instance of ImageViewController

JavaScript

Then you will need to get the controller and call the setImageView() method from RootLayoutController to pass its instance

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement