JFXtras / jfxtras

A supporting library for JavaFX, containing helper classes, extended layouts, controls and other interesting widgets.
http://jfxtras.org
Other
599 stars 123 forks source link

ListSpinnerIntegerList.indexOf( size ) doesn't return -1 #17

Closed faerindel closed 9 years ago

faerindel commented 9 years ago

Is that intended?

Because this:

public void start(Stage primaryStage) {
    StackPane root = new StackPane();
    ListSpinner<Integer> spinner = new ListSpinner<>(new ListSpinnerIntegerList(0, 59)).withEditable(true).withStringConverter(StringConverterFactory.forInteger());
    ListSpinnerIntegerList list = new ListSpinnerIntegerList(0, 59);
    System.out.println(list.indexOf(59));
    System.out.println(list.indexOf(60));
    System.out.println(list.indexOf(61));
    System.out.println(list.size());
    root.getChildren().add(spinner);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

Outputs: 59 60 -1 60

And if you introduce 60 in the ListSpinner textfield it throws: java.lang.IllegalArgumentException: Index out of bounds: 60, valid values are 0-59 (any other invalid value just puts last value back, as expected)

I'm using jfxtras-controls-8.0.r3.jar downloaded directly from the Maven repo.

tbee commented 9 years ago

Interesting. I'll take a look tomorrow.

Tom

On 23-12-2014 22:25, faerindel wrote:

Is that intended?

Because this:

public void start(Stage primaryStage) { StackPane root = new StackPane(); ListSpinner spinner = new ListSpinner<>(new ListSpinnerIntegerList(0, 59)).withEditable(true).withStringConverter(StringConverterFactory.forInteger()); ListSpinnerIntegerList list = new ListSpinnerIntegerList(0, 59); System.out.println(list.indexOf(59)); System.out.println(list.indexOf(60)); System.out.println(list.indexOf(61)); System.out.println(list.size()); root.getChildren().add(spinner); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); }

Outputs: 59 60 -1 60

And if you introduce 60 in the ListSpinner textfield it throws: java.lang.IllegalArgumentException: Index out of bounds: 60, valid values are 0-59 (any other invalid value just puts last value back, as expected)

I'm using jfxtras-controls-8.0.r3.jar downloaded directly from the Maven repo.

— Reply to this email directly or view it on GitHub https://github.com/JFXtras/jfxtras/issues/17.

tbee commented 9 years ago

You have indeed uncovered a bug, it was fixed in the current r4-SNAPSHOT. Tests were added to make sure it does not regress. Thanks!