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

ぃ、小莉子 提交于 2019-12-02 11:47:34

问题


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?


回答1:


The answer is to set the background colour of the panes. Opacity has no effect without first setting a background colour.




回答2:


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



来源:https://stackoverflow.com/questions/29595655/javafx-stackpane-in-scenebuilder-how-to-make-only-front-pane-visible-without-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!