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

Spinner listener not invoked on changing value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx23
    • javafx
    • None
    • generic
    • generic

      This issue was found on analysing the ignored Spinner test as part of JDK-8328667
      Listener added to valueProperty of the spinner is not invoked on changing the spinner value using getEditor().setText() method.

      Steps to reproduce the issue:
      Run the source code given below.
      Notice that the spinner value displayed on console is 5 where as the value displayed in Spinner is 3.
      On changing the value manually using spinner, it changes from 5 instead of 3.

      -----BEGIN SOURCE-----
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;


      public class SpinnerSample extends Application {
          int count = 0;

          public void start(Stage stage) {
              Spinner<Integer> spinner = new Spinner<>(0, 10, 5, 1);
              spinner.valueProperty().addListener(o -> {
                  System.out.println("Listener invoked");
                  System.out.println((int)spinner.getValue());
                  count++;
              });
              spinner.getEditor().setText("3");

              System.out.println(count);
              System.out.println((int)spinner.getValue());

              VBox vBox = new VBox(spinner);

              Scene scene = new Scene(vBox, 400, 200);
              stage.setScene(scene);
              stage.show();
          }

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

      }
      -----END SOURCE-----

            Unassigned Unassigned
            kpk Karthik P K
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: