-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8
In the below example, there is a keyListener, which on typing Delete on a selected Item, will set some value to null. This value is shown in the second column of the tree (so the cellValueFactory of the second column of the tree is bound to this valueProperty).
This value decides whether the treeItem has children or not (so if value is null, children should be cleared).
If in the below example (check attached code) ,:
1- you click on the "hello" item
2- expand the item so that child item is visible (this is important otherwise the bug does not happen)
3-Type Delete
The below exception is thrown:
java.lang.IndexOutOfBoundsException: Index: 3, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
at javafx.scene.Parent.layout(Parent.java:1026)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:513)
at javafx.scene.Scene.doLayoutPass(Scene.java:484)
at javafx.scene.Scene.access$3900(Scene.java:169)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2199)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:662)
IMPORTANT NOTICE: if you remove the cell value factory of the second column , i.e. comment the below lines, the exception disappears!
TreeTableColumn<String, String> valueCol = new TreeTableColumn<String, String>("Value");
<!--COMMENT THIS CELL VALUE FACTORY -->
valueCol.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<String, String> arg0) {
return ((SampleTreeItem) arg0.getValue()).file.valueProperty();
}
});
Alternatively, f you do not set the file.value to null, the exception also disappears.
I suspect it has to do with the fact that the cellValueFactory is binding to the valueProperty(), which we are setting to null explicitly. Seems the cellValueFactory does not like the "null" values.
This value decides whether the treeItem has children or not (so if value is null, children should be cleared).
If in the below example (check attached code) ,:
1- you click on the "hello" item
2- expand the item so that child item is visible (this is important otherwise the bug does not happen)
3-Type Delete
The below exception is thrown:
java.lang.IndexOutOfBoundsException: Index: 3, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
at javafx.scene.Parent.layout(Parent.java:1026)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:513)
at javafx.scene.Scene.doLayoutPass(Scene.java:484)
at javafx.scene.Scene.access$3900(Scene.java:169)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2199)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:662)
IMPORTANT NOTICE: if you remove the cell value factory of the second column , i.e. comment the below lines, the exception disappears!
TreeTableColumn<String, String> valueCol = new TreeTableColumn<String, String>("Value");
<!--COMMENT THIS CELL VALUE FACTORY -->
valueCol.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<String, String> arg0) {
return ((SampleTreeItem) arg0.getValue()).file.valueProperty();
}
});
Alternatively, f you do not set the file.value to null, the exception also disappears.
I suspect it has to do with the fact that the cellValueFactory is binding to the valueProperty(), which we are setting to null explicitly. Seems the cellValueFactory does not like the "null" values.