Reputation: 1401
Related question: Nodes - Choose the Layer to appear JavaFX2
I'm using JavaFx 8 with SceneBuilder 2. I have a number of panes as children of a StackPane and I would like to make only the front Node visible. I need to do this without disabling visibility of the other children, and I've tried to do this using the opacity setting seen below (ignore the fact that visibility is disabled):
Without disabling the visiblity of the other child nodes, the children are always drawn over each other, even when using different blend modes (SRC_OVER & SRC_ATOP), as seen below:
The reason I would like to avoid setting visibility to false of the child elements is that I want to animate a transition between the panes, in which one pane needs to be draw over the top of the other.
I must be missing something obvious here, but I can't see what it is?
Upvotes: 1
Views: 3311
Reputation: 11
You could try setting the visibility to false.
To do that, call setVisible(false)
on the node you'd like to render invisible in the StackPane.
See Node::setVisible
Upvotes: 1
Reputation: 1401
The answer is to set the background colour of the panes. Opacity has no effect without first setting a background colour.
Upvotes: 2