FULL PRODUCT VERSION :
java 9
ADDITIONAL OS VERSION INFORMATION :
windows 10
A DESCRIPTION OF THE PROBLEM :
issue 1:
when selecting the checkbox for the root node, some sub-nodes are not selected
issue 2:
CheckBoxTreeItem.isSelected() is not correct when de-selecting a subnode, the parent will be still considered selected
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
issue 1:
- select node 3
- unselect one of the sub-node 3
- select the root node
issue 2:
- select node 3
- unselect one of the sub-node 3
- press B1
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
issue 1:
all nodes to be selected
issue 2:
node 3 isSelected() return true
ACTUAL -
issue 1:
- sub-node 3 is still not selected
issue 2:
node 3 isSelected() return false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- 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 ----------
java 9
ADDITIONAL OS VERSION INFORMATION :
windows 10
A DESCRIPTION OF THE PROBLEM :
issue 1:
when selecting the checkbox for the root node, some sub-nodes are not selected
issue 2:
CheckBoxTreeItem.isSelected() is not correct when de-selecting a subnode, the parent will be still considered selected
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
issue 1:
- select node 3
- unselect one of the sub-node 3
- select the root node
issue 2:
- select node 3
- unselect one of the sub-node 3
- press B1
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
issue 1:
all nodes to be selected
issue 2:
node 3 isSelected() return true
ACTUAL -
issue 1:
- sub-node 3 is still not selected
issue 2:
node 3 isSelected() return false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- 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 ----------
- duplicates
-
JDK-8190752 TreeView with CheckBoxTreeItem: sub-node is not selected by selecting the parent: JDK-8177861 new Issue
-
- Open
-