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

[TreeView, TreeTableView] can lose arrows while scrolling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • 8.0b66

      Look at the attached movie. When scrollTo is called, ROOT losts its arrow. On the second launch, "item-1" lost its arrow.

      What is interesting, I see, that arrows can disappear in different cases:
      a) scrollTo call
      b) selection (like shift+down) which makes control to do scrolling (a hiden scrollTo call could be there), so, that newly appeared TreeItem has no arrow.

      Use this code to reproduce:
      (just click button, or select item-1 and click button)

      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.beans.property.BooleanProperty;
      import javafx.beans.property.SimpleBooleanProperty;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeView;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestTextApp11 extends Application {

          @Override
          public void start(Stage stage) {
              final TreeView tv = new TreeView();
              tv.setPrefWidth(200);
              tv.setPrefHeight(200);
              tv.setRoot(new TreeItem("ROOT"));

              for (int i = 0; i < 6; i++) {
                  TreeItem level1Item = new TreeItem("item-" + String.valueOf(i));
                  tv.getRoot().getChildren().add(level1Item);
                  level1Item.setExpanded(true);
                  for (int j = 0; j < 6; j++) {
                      TreeItem level2Item = new TreeItem("item-" + String.valueOf(i) + "-" + String.valueOf(j));
                      level1Item.getChildren().add(level2Item);
                  }
              }

              tv.getRoot().setExpanded(true);

              final BooleanProperty switcher = new SimpleBooleanProperty(true);

              Button b = new Button("scroll");
              b.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                      tv.requestFocus();
                      new Thread(new Runnable() {
                          @Override
                          public void run() {
                              for (int i = 0; i < 4; i++) {
                                  try {
                                      Thread.sleep(500);
                                  } catch (InterruptedException ex) {
                                      Logger.getLogger(TestTextApp11.class.getName()).log(Level.SEVERE, null, ex);
                                  }
                                  Platform.runLater(new Runnable() {
                                      @Override
                                      public void run() {
                                          switcher.set(!switcher.get());
                                          if (switcher.get()) {
                                              tv.scrollTo(-10);
                                          } else {
                                              tv.scrollTo(100);
                                          }
                                      }
                                  });
                              }
                          }
                      }).start();
                  }
              });

              VBox vb = new VBox();
              vb.getChildren().addAll(tv, b);

              Scene scene = new Scene(vb, 300, 300);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              Application.launch(TestTextApp11.class, args);
          }
      }

      Affected tests:
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/scrollToTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/singleRowSelectionTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/multipleRowSelectionTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/keyboardShiftUpDownTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/keyboardShiftSequentialMultipleSelectionTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/keyboardRangeMultipleSelectionTest
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/keyboardHomeEndCycle
      ControlsAutomatedTestSuite/javafx/scene/control/test/treeview/TreeViewTest/keyboardCtrlHomeEndTest

            jgiles Jonathan Giles
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: