• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Overlay a menu over a Scene?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone. I can do a little bit with JavaFX, but I am a newbie, and this is stumping me.

I want to overlay a menu with options like save, load, exit, etc. over a JavaFX Scene. I am not sure what this type of menu is commonly called, or if it has a specific name.

Here is a visual example of what I want to do that I made by combining screen-shots of Scenes with GIMP:



I haven't been able to find anything in JavaFX that would allow me to just overlay a menu on top of other visual elements. It's like everything needs to be on the same layer.

I am not asking you to write my code for me (though I won't object if you want to), but I could use some advice about how to do this. Is there some JavaFX class type that would make what I want to do fairly easy?
 
Sheriff
Posts: 6026
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Phil Patterson!

There seems to be three ways to do this.  One is Node#toBack and Node#toFront and another is Node#viewOrder if you have JavaFX 9 or above.  The last way is to manually control the child order in the scene graph.  That is, the Nodes of a Scene are painted from first to last, with the last being on top.  You can use Collections.swap(...) to change the elements in a List like the children of a Pane.  See this answer for more details.
 
Phil Patterson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! I did the toFront() and toBack() thing, and it worked very well.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!