-
Bug
-
Resolution: Fixed
-
P3
-
9, 10
FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
1
ADDITIONAL OS VERSION INFORMATION :
Linux proteus3 4.13.0-25-generic #29-Ubuntu SMP Mon Jan 8 21:14:41 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
ListChangeListener does not report correct items when using clearAndSelect on the selection model.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
+[zero, one, two]
-[zero]
-[two]
ACTUAL -
+[zero, one, two]
-[zero]
-[one]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static javafx.scene.control.SelectionMode.MULTIPLE;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
final ObservableList<String> listitems = FXCollections.observableArrayList("zero", "one", "two");
@Override
public void start(Stage primaryStage) {
final ListView<String> lv = new ListView<>();
lv.setItems(listitems);
final HBox hbox = new HBox();
hbox.getChildren().add(lv);
primaryStage.setScene(new Scene(hbox));
lv.getSelectionModel().setSelectionMode(MULTIPLE);
lv.getSelectionModel().getSelectedItems().addListener((ListChangeListener<String>) ch -> {
while (ch.next()) {
if (ch.wasAdded()) {
System.out.println("+" + ch.getAddedSubList());
}
if (ch.wasRemoved()) {
System.out.println("-" + ch.getRemoved());
}
}
});
primaryStage.show();
Platform.runLater(() -> lv.getSelectionModel().selectAll());
Platform.runLater(() -> lv.getSelectionModel().clearAndSelect(1));
}
public static void main(String[] args) {
Application.launch(args);
}
}
---------- END SOURCE ----------
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
1
ADDITIONAL OS VERSION INFORMATION :
Linux proteus3 4.13.0-25-generic #29-Ubuntu SMP Mon Jan 8 21:14:41 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
ListChangeListener does not report correct items when using clearAndSelect on the selection model.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
+[zero, one, two]
-[zero]
-[two]
ACTUAL -
+[zero, one, two]
-[zero]
-[one]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static javafx.scene.control.SelectionMode.MULTIPLE;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
final ObservableList<String> listitems = FXCollections.observableArrayList("zero", "one", "two");
@Override
public void start(Stage primaryStage) {
final ListView<String> lv = new ListView<>();
lv.setItems(listitems);
final HBox hbox = new HBox();
hbox.getChildren().add(lv);
primaryStage.setScene(new Scene(hbox));
lv.getSelectionModel().setSelectionMode(MULTIPLE);
lv.getSelectionModel().getSelectedItems().addListener((ListChangeListener<String>) ch -> {
while (ch.next()) {
if (ch.wasAdded()) {
System.out.println("+" + ch.getAddedSubList());
}
if (ch.wasRemoved()) {
System.out.println("-" + ch.getRemoved());
}
}
});
primaryStage.show();
Platform.runLater(() -> lv.getSelectionModel().selectAll());
Platform.runLater(() -> lv.getSelectionModel().clearAndSelect(1));
}
public static void main(String[] args) {
Application.launch(args);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8255935 MultipleSelectionModel provides incorrect 'removed' sub-list in change events
-
- Closed
-
- relates to
-
JDK-8273324 IllegalArgumentException: fromIndex(0) > toIndex(-1) after clear and select TableCell
-
- Resolved
-
-
JDK-8255935 MultipleSelectionModel provides incorrect 'removed' sub-list in change events
-
- Closed
-