properties - JavaFX - Add a Listener to a Pane to check if it is showing -



properties - JavaFX - Add a Listener to a Pane to check if it is showing -

i working on javafx lastly couple of months. trying find way implement listener fired whenever particular pane shown on root pane/scene. in java, implement using ancestorlistener on jpanel shown below, cannot find equivalent method on javafx.

jpanel panel = new jpanel (); panel.addancestorlistener ( new ancestorlistener () { public void ancestoradded ( ancestorevent event ) { system.out.println("this panel shown on screen now"); } public void ancestorremoved ( ancestorevent event ){} public void ancestormoved ( ancestorevent event ){} } );

you can observe sceneproperty(). tell if pane (or other node) part of scene graph:

pane.sceneproperty().addlistener((obs, oldscene, newscene) -> { if (newscene == null) { // not showing... } else { // showing ... } });

if want go further, , see if pane part of scene graph in window showing, can utilize easybind:

easybind.select(pane.sceneproperty()) .select(scene::windowproperty) .select(window::showingproperty) .orelse(false) .addlistener((obs, wasshowing, isnowshowing) -> { if (isnowshowing) { // pane showing in window... } else { // pane not showing in window... });

properties javafx listener javafx-8 show

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -