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

Long item breakes vertical listview

XMLWordPrintable

      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);
          }
      }

            jgiles Jonathan Giles
            shurailine Aleksandre Iline
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: