Isaac
Isaac

Reputation: 1401

JavaFx StackPane in SceneBuilder, how to make only front pane visible without setting disabling visibility of others?

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):

Opacity already set

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:

enter image description here

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

Answers (2)

Niels Lachat
Niels Lachat

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

Isaac
Isaac

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

Related Questions