Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+30 votes

I have a separate window that suggests possible auto tracks to the user. I also have a ManualTrackWindowController
I was wondering if it's possible to have the "suggesting" controller be able to use my Man...Controller's buttons and such e.g. be able to draw stuff on the Manual...Controller's canvas from the other controller.

asked in CSC285_Fall2018 by (1 point)

1 Answer

+11 votes

Yes. You just need to get access to a reference to the controller that you want to manipulate, which you can do by:

  • When one window creates the other, it can get the Controller from the FXMLLoader (just like in the Day14_DemoOpenNextWindow project), and then it could pass a reference to itself (this) into a method that it calls on the recently created controller. That recently created controller could store a reference back to the "parent controller", and call methods whatever methods on it as necessary.

(There may be other solutions to your underlying problem too, however...)

answered by (5.7k points)
...