--- old/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java 2014-05-20 09:51:41.000000000 -0400 +++ new/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java 2014-05-20 09:51:41.000000000 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; +import javafx.beans.value.ChangeListener; import javafx.beans.value.WritableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -106,7 +107,7 @@ this.control = control; this.control.indeterminateProperty().addListener(indeterminateListener); this.control.progressProperty().addListener(progressListener); - + this.control.sceneProperty().addListener(sceneChangeListener); initialize(); } @@ -138,7 +139,6 @@ } @Override public void dispose() { - super.dispose(); if (spinner != null) { if (spinner.indeterminateTimeline != null) { spinner.indeterminateTimeline.stop(); @@ -147,7 +147,9 @@ } control.indeterminateProperty().removeListener(indeterminateListener); control.progressProperty().removeListener(progressListener); - control = null; + control.sceneProperty().removeListener(sceneChangeListener); + + super.dispose(); } @Override protected void layoutChildren(final double x, final double y, @@ -172,11 +174,16 @@ initialize(); }; - private final InvalidationListener progressListener = new InvalidationListener() { - @Override public void invalidated(Observable valueModel) { - if (determinateIndicator != null) { - determinateIndicator.updateProgress(((DoubleProperty)valueModel).doubleValue()); - } + private final InvalidationListener progressListener = valueModel -> { + if (determinateIndicator != null) { + determinateIndicator.updateProgress(((DoubleProperty)valueModel).doubleValue()); + } + }; + + private final ChangeListener sceneChangeListener = (observable, oldValue, newValue) -> { + // if ProgressIndicator was removed from scene and then added back in... + if (oldValue == null) { + initialize(); } };