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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -