• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

switch between scenes (not stage) in javafx

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic