-
Bug
-
Resolution: Fixed
-
P4
-
8
-
Java 8.0 b 129
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Bug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) {
ObservableList<String> fxList = FXCollections.observableArrayList("A", "B", "C");
final ListView<String> listView = new ListView<String>(fxList);
Button button = new Button("Remove");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
ObservableList<String> selectedItems = listView.getSelectionModel().getSelectedItems();
System.out.println("selectedItems = " + selectedItems);
listView.getItems().removeAll(selectedItems);
}
});
VBox vBox = new VBox();
vBox.getChildren().setAll(listView, button);
stage.setScene(new Scene(vBox));
stage.show();
}
}
Try it on a list, but only select the first item.
Instead of just the first item being removed, the entire list is removed. It basically removes all items past the first selected item.
Possibly related toRT-24371
import java.util.List;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Bug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) {
ObservableList<String> fxList = FXCollections.observableArrayList("A", "B", "C");
final ListView<String> listView = new ListView<String>(fxList);
Button button = new Button("Remove");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
ObservableList<String> selectedItems = listView.getSelectionModel().getSelectedItems();
System.out.println("selectedItems = " + selectedItems);
listView.getItems().removeAll(selectedItems);
}
});
VBox vBox = new VBox();
vBox.getChildren().setAll(listView, button);
stage.setScene(new Scene(vBox));
stage.show();
}
}
Try it on a list, but only select the first item.
Instead of just the first item being removed, the entire list is removed. It basically removes all items past the first selected item.
Possibly related to
- relates to
-
JDK-8254040 [testbug] Need additional regressions tests for ObservableList removeAll / retainAll
- Resolved