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

ListView renders 'null' inconsistently.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P4
    • Resolution: Incomplete
    • 8
    • 8
    • javafx
    • jdk1.8.0b86

    Description

      To reproduce click the "Run" button.

      import com.sun.javafx.runtime.VersionInfo;
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ListView;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;
      import static javafx.collections.FXCollections.*;
      import javafx.collections.ObservableList;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Orientation;
      import javafx.scene.control.Button;
      import javafx.scene.layout.VBox;

      public class Main extends Application {

          private static ObservableList<String> data_first
                  = observableArrayList("un", "deux" , "trois");
          private static ObservableList<String> data_second
                  = observableArrayList("un", "deux" , "trois");

          private ListView<String> lv_first;
          private ListView<String> lv_second;
          
          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              stage.setTitle(VersionInfo.getRuntimeVersion());
              stage.setScene(createScene());
              stage.show();
          }

          private Scene createScene() {
              HBox root = new HBox();
              lv_first = new ListView(data_first);
              lv_first.setPrefSize(200, 200);
              lv_first.setMaxSize(200, 200);
              lv_first.setOrientation(Orientation.HORIZONTAL);
              
              lv_second = new ListView(data_second);
              lv_second.setPrefSize(200, 200);
              lv_second.setMaxSize(200, 200);
              lv_second.setOrientation(Orientation.HORIZONTAL);
              
              Button add_remove = new Button("Run");
              add_remove.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent event) {
                      lv_first.getItems().add(0, null);
                      
                      lv_second.getItems().remove(0);
                      lv_second.getItems().add(0, null);
                  }
              });
              
              root.getChildren().addAll(add_remove, new VBox(3, lv_first, lv_second));
              
              return new Scene(root);
          }
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: