This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JavaFX and the fly likes Dialog with owner: update first window causes @fxml fx:id nodes to be null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Dialog with owner: update first window causes @fxml fx:id nodes to be null" Watch "Dialog with owner: update first window causes @fxml fx:id nodes to be null" New topic
Author

Dialog with owner: update first window causes @fxml fx:id nodes to be null

Fhomas Peeters
Greenhorn

Joined: May 23, 2011
Posts: 4
I've got a rather basic JavaFx 2.x pet project which has a main window with stage and a dialog with a new Stage but using the main window as owner.

When the dialog is shown there's a button that imports something to the file system. When this occurs I need to update the controllers and views of the main window and that's where I'm puzzled.

Upon initializing the main window all @FXML injected nodes are available. However when the button in the dialog is clicked, a custom event gets fired which is successfully picked up by the controller of the main window. However when I try to access the @FXML injected nodes they're all null. The controller also has a different memory signature so it's basically a different object.


Dialog caller controller with event handler:



Dialog controller firing the event



I'm rather new in JavaFx and I've never used it professionally.
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 130
    
    9
I don't think your error is in the code you posted.

To get help you will probably need to create an SSCCE.

You may get more help if you post your SSCCE to the Oracle JavaFX forum, which is more active than the JavaRanch JavaFX forum.
Fhomas Peeters
Greenhorn

Joined: May 23, 2011
Posts: 4
John Damien Smith wrote:I don't think your error is in the code you posted.

To get help you will probably need to create an SSCCE.

You may get more help if you post your SSCCE to the Oracle JavaFX forum, which is more active than the JavaRanch JavaFX forum.


You're right. And sorry for not mentioning this, I figured it out.

The problem was that I:
1. violated the MVC pattern by using a controller that extends VBox.
2. I needed to use the correct naming convention for nested controllers.

If you want I'll elaborate further.

But thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dialog with owner: update first window causes @fxml fx:id nodes to be null
 
Similar Threads
javafax, button action..NEED HELP PLEASE!!!
not able to understand the output of the following piece of code ?
Queston on exceptions
JavaFX, Scene Builder, and basic issues with threads/tasks
Runtime exceptions??