--- old/modules/javafx.controls/src/main/java/javafx/scene/control/skin/ProgressIndicatorSkin.java 2017-09-18 17:34:58.244235049 +0530 +++ new/modules/javafx.controls/src/main/java/javafx/scene/control/skin/ProgressIndicatorSkin.java 2017-09-18 17:34:58.040235049 +0530 @@ -255,6 +255,63 @@ } } + /** {@inheritDoc} */ + @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { + double minWidth = 0.0; + + if (spinner != null && control.isIndeterminate()) { + minWidth = spinner.minWidth(-1); + } else if (determinateIndicator != null) { + minWidth = determinateIndicator.minWidth(-1); + } + return minWidth; + } + + /** {@inheritDoc} */ + @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { + double minHeight = 0.0; + + if (spinner != null && control.isIndeterminate()) { + minHeight = spinner.minHeight(-1); + } else if (determinateIndicator != null) { + minHeight = determinateIndicator.minHeight(-1); + } + return minHeight; + } + + /** {@inheritDoc} */ + @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { + double prefWidth = 0.0; + + if (spinner != null && control.isIndeterminate()) { + prefWidth = spinner.prefWidth(height); + } else if (determinateIndicator != null) { + prefWidth = determinateIndicator.prefWidth(height); + } + return prefWidth; + } + + /** {@inheritDoc} */ + @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { + double prefHeight = 0.0; + + if (spinner != null && control.isIndeterminate()) { + prefHeight = spinner.prefHeight(width); + } else if (determinateIndicator != null) { + prefHeight = determinateIndicator.prefHeight(width); + } + return prefHeight; + } + + /** {@inheritDoc} */ + @Override protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { + return computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); + } + + /** {@inheritDoc} */ + @Override protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { + return computePrefHeight(width, topInset, rightInset, bottomInset, leftInset); + } /*************************************************************************** --- /dev/null 2017-09-18 16:12:35.589024000 +0530 +++ new/modules/javafx.controls/src/test/java/test/javafx/scene/control/ProgressIndicatorTest.java 2017-09-18 17:34:58.708235049 +0530 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011, 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.javafx.scene.control; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + + +import javafx.scene.control.ProgressIndicator; +import javafx.scene.Scene; +import javafx.stage.Stage; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.geometry.Pos; +import com.sun.javafx.tk.Toolkit; + +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class ProgressIndicatorTest { + Toolkit tk; + + @Before public void setup() { + tk = Toolkit.getToolkit(); + } + + @Test public void progressIndicatorHeightTest() { + ProgressIndicator pi = new ProgressIndicator(0.5); + + HBox hb = new HBox(); + hb.setAlignment(Pos.CENTER); + hb.getChildren().addAll(pi); + + Scene scene = new Scene(hb, 400, 400); + Stage stage = new Stage(); + stage.setScene(scene); + stage.show(); + tk.firePulse(); + + // Test the ProgressIndicator height is non zero and + // does not occupy entire height of the scene. + int x = Double.compare(0.0, pi.getHeight()); + assertTrue(x != 0); + + x = Double.compare(400.0, pi.getHeight()); + assertTrue(x != 0); + } + + @Test public void progressIndicatorWidthTest() { + ProgressIndicator pi = new ProgressIndicator(0.5); + + VBox vb = new VBox(); + vb.setAlignment(Pos.CENTER); + vb.getChildren().addAll(pi); + + Scene scene = new Scene(vb, 400, 400); + Stage stage = new Stage(); + stage.setScene(scene); + stage.show(); + + tk.firePulse(); + + // Test the ProgressIndicator width is non zero and + // does not occupy entire width of the scene. + int x = Double.compare(0.0, pi.getWidth()); + assertTrue(x != 0); + + x = Double.compare(400.0, pi.getWidth()); + assertTrue(x != 0); + } +} +