-
Bug
-
Resolution: Duplicate
-
P3
-
jfx11, jfx12, jfx13, 10, jfx14
A DESCRIPTION OF THE PROBLEM :
All cells in a TreeTableView should have their content indented appropriately based on the number of parents and children of that cell.
For example, a root item should have no indentation if it has no children.
If an item has children, that item's content should be indented to factor in the drop down arrow symbol automatically rendered on the left side of the cell.
If an item is the child of another item, both the drop down arrow and the content should be indented by more than that of its parent.
In JavaFX 11, any TreeTableCell that has content set via Labeled#setGraphic has correct indentation for the drop down arrow symbol, but has no indentation for the graphic. This causes the graphic to overlap with the drop down arrow.
Labeled#setText, by contrast, exhibits correct behaviour.
REGRESSION : Last worked in version 8u241
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All items should be indented correctly, including "Third Item".
ACTUAL -
In given example, the text "Third Item" is set on the far left of its cell; and the drop down arrow is in the expected position.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableCell;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class MyApplication extends Application
{
public void start(Stage stage)
{
final VBox rootPane = new VBox();
rootPane.getChildren().add(createTreeTableView());
Scene scene = new Scene(rootPane);
stage.setScene(scene);
stage.show();
}
public TreeTableView<String> createTreeTableView()
{
final TreeTableView<String> tableView = new TreeTableView<>();
tableView.getColumns().add(createColumn("My Column"));
final TreeItem<String> rootItem = new TreeItem<>("Root");
rootItem.setExpanded(true);
final TreeItem<String> item2 = new TreeItem<>("Second Item"); // Will set this one as text
rootItem.getChildren().add(item2);
item2.getChildren().add(new TreeItem<>("Second's Child"));
final TreeItem<String> item3 = new TreeItem<>("Third Item"); // Will set this one as a graphic
rootItem.getChildren().add(item3);
item3.getChildren().add(new TreeItem<>("Third's Child"));
tableView.setRoot(rootItem);
return tableView;
}
public TreeTableColumn<String, String> createColumn(String columnName)
{
final TreeTableColumn<String, String> column = new TreeTableColumn<>(columnName);
column.setCellValueFactory(row -> new SimpleStringProperty(row.getValue().getValue()));
column.setCellFactory(tc -> new TreeTableCell<>()
{
@Override
protected void updateItem(String item, boolean isEmpty)
{
super.updateItem(item, isEmpty);
if (item == null || isEmpty)
{
setText("");
setGraphic(null);
}
else
{
if (item.equals("Third Item"))
{
setGraphic(new Label(item));
}
else
{
setText(item);
}
}
}
});
return column;
}
}
---------- END SOURCE ----------
FREQUENCY : always
All cells in a TreeTableView should have their content indented appropriately based on the number of parents and children of that cell.
For example, a root item should have no indentation if it has no children.
If an item has children, that item's content should be indented to factor in the drop down arrow symbol automatically rendered on the left side of the cell.
If an item is the child of another item, both the drop down arrow and the content should be indented by more than that of its parent.
In JavaFX 11, any TreeTableCell that has content set via Labeled#setGraphic has correct indentation for the drop down arrow symbol, but has no indentation for the graphic. This causes the graphic to overlap with the drop down arrow.
Labeled#setText, by contrast, exhibits correct behaviour.
REGRESSION : Last worked in version 8u241
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All items should be indented correctly, including "Third Item".
ACTUAL -
In given example, the text "Third Item" is set on the far left of its cell; and the drop down arrow is in the expected position.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableCell;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class MyApplication extends Application
{
public void start(Stage stage)
{
final VBox rootPane = new VBox();
rootPane.getChildren().add(createTreeTableView());
Scene scene = new Scene(rootPane);
stage.setScene(scene);
stage.show();
}
public TreeTableView<String> createTreeTableView()
{
final TreeTableView<String> tableView = new TreeTableView<>();
tableView.getColumns().add(createColumn("My Column"));
final TreeItem<String> rootItem = new TreeItem<>("Root");
rootItem.setExpanded(true);
final TreeItem<String> item2 = new TreeItem<>("Second Item"); // Will set this one as text
rootItem.getChildren().add(item2);
item2.getChildren().add(new TreeItem<>("Second's Child"));
final TreeItem<String> item3 = new TreeItem<>("Third Item"); // Will set this one as a graphic
rootItem.getChildren().add(item3);
item3.getChildren().add(new TreeItem<>("Third's Child"));
tableView.setRoot(rootItem);
return tableView;
}
public TreeTableColumn<String, String> createColumn(String columnName)
{
final TreeTableColumn<String, String> column = new TreeTableColumn<>(columnName);
column.setCellValueFactory(row -> new SimpleStringProperty(row.getValue().getValue()));
column.setCellFactory(tc -> new TreeTableCell<>()
{
@Override
protected void updateItem(String item, boolean isEmpty)
{
super.updateItem(item, isEmpty);
if (item == null || isEmpty)
{
setText("");
setGraphic(null);
}
else
{
if (item.equals("Third Item"))
{
setGraphic(new Label(item));
}
else
{
setText(item);
}
}
}
});
return column;
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8231644 TreeTableView Regression: Indentation wrong using Label as column content type
- Resolved