aspose file tools*
The moose likes JavaFX and the fly likes switch between scenes (not stage) in javafx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "switch between scenes (not stage) in javafx" Watch "switch between scenes (not stage) in javafx" New topic
Author

switch between scenes (not stage) in javafx

craig peddie
Greenhorn

Joined: May 15, 2013
Posts: 12
I'm trying to move from swing to javafx and have run into a problems I've spent all afternoon trying to figure out to no avail. I'm using a standard border pane, with a top Hbox, left Vertical pane then the main user content is in the center pane. Depending on what buttons the user presses in either the top or left menu panes, I want to switch out the content that is being displayed in the main center pane. I have been able to change the anchor pane that is being shown in this area, but am unable to get get at any other fields that I have defined in the different fxml files for pane1, pane2 etc. When I try and access them after I load the new fxml file they are always null.

I'm sure there has to be a simple way of doing this, but I haven't been able to find it.

Any ideas would be appreciated....

Thanks
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 101
    
    7
This is a common question regarding FXML.

I'll just provide some links to answers from other forums.
http://stackoverflow.com/questions/18619394/loading-new-fxml-in-the-same-scene "Loading new fxml in the same scene"
https://gist.github.com/jewelsea/6460130 "Small JavaFX framework for swapping in and out child panes in a main FXML container."
http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml "Passing Parameters JavaFX FXML"
https://blogs.oracle.com/acaicedo/entry/managing_multiple_screens_in_javafx1 "Managing Multiple Screens in JavaFX"
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 101
    
    7
Also see a post on switching in and out scene components:
http://stackoverflow.com/questions/13556637/how-to-have-menus-in-java-desktop-application
The last link is if you are not using fxml (I know you are using fxml in your current case, but just providing the link for reference in case you need to do it in the future).
craig peddie
Greenhorn

Joined: May 15, 2013
Posts: 12
Thank you!! This is exactly the answer I spent most of today googling for. I can't believe this never popped up in any of my searches. I'm off to the races now....

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: switch between scenes (not stage) in javafx
 
Similar Threads
Form get input data
javafax, button action..NEED HELP PLEASE!!!
Scene Builder extensions
Generating FXML file from JavaFX Java code
JavaFX/ Swing Compatibility?