Description
Hello,
when a TreeView contains some elements, and one of the elements is set to be not expaneded, selecting that element using getSelectionModel.select() expands that element.
Sample code:
package bugreports;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class TreeViewExpansionBug extends Application
{
@Override
public void start(final Stage primaryStage)
{
final TreeItem<String> a = new TreeItem<>("a");
final TreeItem<String> b = new TreeItem<>("b");
final TreeItem<String> middle = new TreeItem<>("middle");
middle.getChildren().addAll(a, b);
final TreeItem<String> root = new TreeItem<>("root");
root.getChildren().add(middle);
root.setExpanded(true);
final TreeView<String> view = new TreeView<>();
view.setRoot(root);
final Button select = new Button("select");
select.setOnAction(e -> view.getSelectionModel().select(middle));
final BorderPane pane = new BorderPane();
pane.setCenter(view);
pane.setBottom(select);
primaryStage.setScene(new Scene(pane));
primaryStage.show();
}
public static void main(final String[] args)
{
launch(args);
}
}
Steps to reproduce:
1) Launch. Now you see the nodes root and middle, with middle being collapsed
2) click on button select. Now middle, is selected, but also expanded
when a TreeView contains some elements, and one of the elements is set to be not expaneded, selecting that element using getSelectionModel.select() expands that element.
Sample code:
package bugreports;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class TreeViewExpansionBug extends Application
{
@Override
public void start(final Stage primaryStage)
{
final TreeItem<String> a = new TreeItem<>("a");
final TreeItem<String> b = new TreeItem<>("b");
final TreeItem<String> middle = new TreeItem<>("middle");
middle.getChildren().addAll(a, b);
final TreeItem<String> root = new TreeItem<>("root");
root.getChildren().add(middle);
root.setExpanded(true);
final TreeView<String> view = new TreeView<>();
view.setRoot(root);
final Button select = new Button("select");
select.setOnAction(e -> view.getSelectionModel().select(middle));
final BorderPane pane = new BorderPane();
pane.setCenter(view);
pane.setBottom(select);
primaryStage.setScene(new Scene(pane));
primaryStage.show();
}
public static void main(final String[] args)
{
launch(args);
}
}
Steps to reproduce:
1) Launch. Now you see the nodes root and middle, with middle being collapsed
2) click on button select. Now middle, is selected, but also expanded