Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8095160

ProgressBar starts from wrong position when switching from indeterminate to determinate mode

XMLWordPrintable

      Example Code:

      package application;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ProgressBar;
      import javafx.scene.layout.VBox;


      public class Main extends Application {

      private double progress = 0;

      @Override
      public void start(Stage primaryStage) {
      try {

      VBox root = new VBox(10);

      ProgressBar progressBar = new ProgressBar(-1);
      progressBar.setPrefSize(200, 20);

      Button increaseButton = new Button("IncreaseProgress");
      increaseButton.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      progress += 0.1;
      progressBar.setProgress(progress);
      }
      });

      Button resetButton = new Button("Reset");
      resetButton.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      progress = 0;
      progressBar.setProgress(-1);
      }
      });

      root.getChildren().addAll(progressBar, increaseButton, resetButton);

      Scene scene = new Scene(root,400,400);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();

      } catch(Exception e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      launch(args);
      }
      }




       When clicking the "Increase Progress" Button, the ProgressBar switches from indeterminate to determinate mode. The ProgressBar starts from the wrong position (depending on the spinners location).

      Worked fine with 8u5, doesn't work with 8u20.

            msladecek Martin Sládeček
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: