Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get a controller instance

eflores76Dec 4 2013 — edited Dec 23 2013

Hello,  I have been trying to access a Controller instance already loaded in another Class( Class A) using FXMLLoader.load(getClass().getResource("Afile.fxml")).

So when I was invoking the load method in Class B, I realized that method creates another instance of the Controller class of Afile.fxml. And I need to have access to the instance created in the Class A.

So my question is: How can I have access to the Controller instance already loaded in another class (Class A).

Thanks in advance for any help.

Here in code the question that I'm asking:

public class A{

     public void initialize(URL url, ResourceBundle rb) {

           final AnchorPane apBusquedaPadron = FXMLLoader.load(getClass().getResource("busquedaPadron.fxml"));

    }

}

public class B{

     public void initialize(URL url, ResourceBundle rb) {

           final AnchorPane apBusquedaPadron = FXMLLoader.load(getClass().getResource("busquedaPadron.fxml"));

    }

}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 20 2014
Added on Dec 4 2013
8 comments
1,040 views