-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
1. run code below
2. push add
3. scroll hor scrollbar all the way to the right
4. push remove
ListView goes white - no items shown
public class ScrollableListBroken extends Application {
ListView list;
int itemIndex = 0;
@Override
public void start(Stage stage) {
VBox content = new VBox();
list = new ListView();
list.getSelectionModel().addChangeListener(ListViewSelectionModel.SELECTED_ITEM,
new ChangeListener() {
public void handle(Bean bean, PropertyReference<?> pr) {
System.out.println(pr.get(bean));
}
});
for (int i = 0; i < 30; i++) {
list.getItems().add(i);
}
Button btnAdd = new Button("Add");
btnAdd.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
StringBuilder builder = new StringBuilder("l");
for (int i = 0; i < 50; i++) {
builder.append("o");
}
builder.append("ng item");
list.getItems().add(0, builder);
}
});
Button btnRemove = new Button("Remove");
btnRemove.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
list.getItems().remove(0);
}
});
HBox buttons = new HBox();
buttons.getChildren().add(btnAdd);
buttons.getChildren().add(btnRemove);
content.getChildren().add(list);
content.getChildren().add(buttons);
stage.setScene(new Scene(content));
stage.setVisible(true);
}
public static void main(String[] args) {
Launcher.launch(ScrollableListBroken.class, args);
}
}
2. push add
3. scroll hor scrollbar all the way to the right
4. push remove
ListView goes white - no items shown
public class ScrollableListBroken extends Application {
ListView list;
int itemIndex = 0;
@Override
public void start(Stage stage) {
VBox content = new VBox();
list = new ListView();
list.getSelectionModel().addChangeListener(ListViewSelectionModel.SELECTED_ITEM,
new ChangeListener() {
public void handle(Bean bean, PropertyReference<?> pr) {
System.out.println(pr.get(bean));
}
});
for (int i = 0; i < 30; i++) {
list.getItems().add(i);
}
Button btnAdd = new Button("Add");
btnAdd.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
StringBuilder builder = new StringBuilder("l");
for (int i = 0; i < 50; i++) {
builder.append("o");
}
builder.append("ng item");
list.getItems().add(0, builder);
}
});
Button btnRemove = new Button("Remove");
btnRemove.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
list.getItems().remove(0);
}
});
HBox buttons = new HBox();
buttons.getChildren().add(btnAdd);
buttons.getChildren().add(btnRemove);
content.getChildren().add(list);
content.getChildren().add(buttons);
stage.setScene(new Scene(content));
stage.setVisible(true);
}
public static void main(String[] args) {
Launcher.launch(ScrollableListBroken.class, args);
}
}
- relates to
-
JDK-8112072 List is scrolled to the left after deleting an item.
- Resolved