A DESCRIPTION OF THE PROBLEM :
The first item in TreeView is not aligned.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code. Note, that the first item is not aligned. Now click it. It is aligned.
ACTUAL -
Please see this gif https://postimg.cc/3WJV9TCQ
---------- BEGIN SOURCE ----------
public class JavaFxTest10 extends Application {
@Override
public void start(Stage primaryStage) {
VBox root = new VBox(createTreeView());
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("TreeView Example");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
private TreeView createTreeView() {
TreeItem<String> rootItem = new TreeItem<>("Root");
TreeItem<String> item1 = new TreeItem<>("Item 1");
TreeItem<String> item2 = new TreeItem<>("Item 2");
TreeItem<String> item3 = new TreeItem<>("Item 3");
TreeItem<String> item4 = new TreeItem<>("Item 1");
item2.getChildren().add(item3);
rootItem.getChildren().addAll(item1, item2, item4);
TreeView<String> treeView = new TreeView<>(rootItem);
rootItem.setExpanded(true);
treeView.setShowRoot(false);
treeView.setCellFactory(tv -> new TreeCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
setText(item);
setGraphic(new Label("W"));
}
}
});
return treeView;
}
}
---------- END SOURCE ----------
FREQUENCY : always
The first item in TreeView is not aligned.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code. Note, that the first item is not aligned. Now click it. It is aligned.
ACTUAL -
Please see this gif https://postimg.cc/3WJV9TCQ
---------- BEGIN SOURCE ----------
public class JavaFxTest10 extends Application {
@Override
public void start(Stage primaryStage) {
VBox root = new VBox(createTreeView());
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("TreeView Example");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
private TreeView createTreeView() {
TreeItem<String> rootItem = new TreeItem<>("Root");
TreeItem<String> item1 = new TreeItem<>("Item 1");
TreeItem<String> item2 = new TreeItem<>("Item 2");
TreeItem<String> item3 = new TreeItem<>("Item 3");
TreeItem<String> item4 = new TreeItem<>("Item 1");
item2.getChildren().add(item3);
rootItem.getChildren().addAll(item1, item2, item4);
TreeView<String> treeView = new TreeView<>(rootItem);
rootItem.setExpanded(true);
treeView.setShowRoot(false);
treeView.setCellFactory(tv -> new TreeCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
setText(item);
setGraphic(new Label("W"));
}
}
});
return treeView;
}
}
---------- END SOURCE ----------
FREQUENCY : always