I am basically new to Java FX 2.
Scenario:
I have 3 scenes, and I need a way to add a menu bar so that I don't want to explicitly remove the menu bar from the previous scene and add it to a new one. Like some things, the Parent Scene scenario or some menu bar is tied to Stage. I mean, the menu bar is added only once and is always present, regardless of which scene is ahead or not.
If possible. How can I do this.
Here is the default example provided by Oracle Docs of JavaFX http://docs.oracle.com/javafx/2/ui_controls/MenuSample.java.html
public class Main extends Application { final ImageView pic = new ImageView(); final Label name = new Label(); final Label binName = new Label(); final Label description = new Label(); public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); scene.setFill(Color.OLDLACE); MenuBar menuBar = new MenuBar();
So, here the menuBar is added to the scene. if I change the scene and bring another scene ahead ... What will I do. I think I am removing the menuBar from this scene and adding to another or just adding to a new one. so every time I have to do it when I change. Is there any way to avoid this?
source share