FULL PRODUCT VERSION :
JDK 9.0.1
A DESCRIPTION OF THE PROBLEM :
JDK-8088731 : CheckBoxTreeItem: must update check state on modifications to children list
issue 3
-check root
-uncheck node 3
-check sub of node 3
-uncheck root
I fixed issue 1 and 3 in my project
I add in CheckBoxTreeItem.updateDownwards()
cbti.setIndeterminate(false);
private void updateDownwards() {
// If this node is not a leaf, we also put all
// children into the same state as this branch
if (! isLeaf()) {
for (TreeItem<T> child : getChildren()) {
if (child instanceof CheckBoxTreeItem) {
CheckBoxTreeItem<T> cbti = ((CheckBoxTreeItem<T>) child);
cbti.setSelected(isSelected());
cbti.setIndeterminate(false); //My fix
}
}
}
}
maybe it will help.
Sorry for my second letter. But After fixing I have to write for save your time. Thanks
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
JDK-8088731 : CheckBoxTreeItem: must update check state on modifications to children list
issue 3
-check root
-uncheck node 3
-check sub of node 3
-uncheck root
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
node is unchecked
ACTUAL -
node is indeterminate
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.NodeOrientation;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.CheckBoxTreeCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Test1 extends Application
{
@Override
public void start(Stage stage)
{
Button b = new Button("B1");
CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("Root Node");
rootItem.setExpanded(true);
final TreeView<String> tree = new TreeView<>(rootItem);
tree.setEditable(true);
tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
for (int i = 0; i < 8; i++) {
final CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<>("Node" + (i+1));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
rootItem.getChildren().add(checkBoxTreeItem);
}
b.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent e)
{
isSelected(rootItem);
}
});
tree.setRoot(rootItem);
tree.setShowRoot(true);
final BorderPane root = new BorderPane();
root.setCenter(tree);
root.setBottom(b);
final Scene scene = new Scene(root);
scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
stage.setScene(scene);
stage.show();
}
private void isSelected(CheckBoxTreeItem<String> root)
{
boolean selected = root.isSelected();
if(selected)
System.out.println(root.getValue());
else
for(TreeItem<String> item : root.getChildren())
isSelected((CheckBoxTreeItem<String>)item);
}
}
---------- END SOURCE ----------
---------- END SOURCE ----------
JDK 9.0.1
A DESCRIPTION OF THE PROBLEM :
JDK-8088731 : CheckBoxTreeItem: must update check state on modifications to children list
issue 3
-check root
-uncheck node 3
-check sub of node 3
-uncheck root
I fixed issue 1 and 3 in my project
I add in CheckBoxTreeItem.updateDownwards()
cbti.setIndeterminate(false);
private void updateDownwards() {
// If this node is not a leaf, we also put all
// children into the same state as this branch
if (! isLeaf()) {
for (TreeItem<T> child : getChildren()) {
if (child instanceof CheckBoxTreeItem) {
CheckBoxTreeItem<T> cbti = ((CheckBoxTreeItem<T>) child);
cbti.setSelected(isSelected());
cbti.setIndeterminate(false); //My fix
}
}
}
}
maybe it will help.
Sorry for my second letter. But After fixing I have to write for save your time. Thanks
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
JDK-8088731 : CheckBoxTreeItem: must update check state on modifications to children list
issue 3
-check root
-uncheck node 3
-check sub of node 3
-uncheck root
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
node is unchecked
ACTUAL -
node is indeterminate
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.NodeOrientation;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.CheckBoxTreeCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Test1 extends Application
{
@Override
public void start(Stage stage)
{
Button b = new Button("B1");
CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("Root Node");
rootItem.setExpanded(true);
final TreeView<String> tree = new TreeView<>(rootItem);
tree.setEditable(true);
tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView());
for (int i = 0; i < 8; i++) {
final CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<>("Node" + (i+1));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
checkBoxTreeItem.getChildren().add(new CheckBoxTreeItem<>("Sub node" + (i+1)));
rootItem.getChildren().add(checkBoxTreeItem);
}
b.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent e)
{
isSelected(rootItem);
}
});
tree.setRoot(rootItem);
tree.setShowRoot(true);
final BorderPane root = new BorderPane();
root.setCenter(tree);
root.setBottom(b);
final Scene scene = new Scene(root);
scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
stage.setScene(scene);
stage.show();
}
private void isSelected(CheckBoxTreeItem<String> root)
{
boolean selected = root.isSelected();
if(selected)
System.out.println(root.getValue());
else
for(TreeItem<String> item : root.getChildren())
isSelected((CheckBoxTreeItem<String>)item);
}
}
---------- END SOURCE ----------
---------- END SOURCE ----------
- duplicates
-
JDK-8177861 TreeView with CheckBoxTreeItem: sub-node is not selected by selecting the parent
- Open
- relates to
-
JDK-8088731 CheckBoxTreeItem: must update check state on modifications to children list
- Open