-
Bug
-
Resolution: Duplicate
-
P4
-
fx2.0
-
JavaFX 2.0 beta b34 + JDK 1.6.0_25 + WinXP SP3
Regression: NullPointerException happens if trying to change any item of a ListView directly from its ObservableList
Broken: JavaFX 2.0 beta b34 + JDK 1.6.0_25 + WinXP SP3
Working: JavaFX 2.0 beta b32 + JDK 1.6.0_25 + WinXP SP3
If a ListView is constructed on an ObservableList, say "ol", then, calling
ol.set(int, String) will cause NullPointerException.
Note that this problem only happened with b34, while, everything was fine\
with b32.
How to re-produce:
1. Run the sample app(codes below)
2. Click the <edit> button
3. With b32, you will see the first item in the ListView is changed to "brown"
With b34, nothing happens but you will see below exception
java.lang.NullPointerException
at javafx.scene.control.ListCell$5.invalidated(ListCell.java:131)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:62)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:116)
at javafx.scene.control.ListCell.setListView(ListCell.java:89)
at javafx.scene.control.ListCell.impl_updateListView(ListCell.java:252)
at com.sun.javafx.scene.control.skin.ListViewSkin.updateCellCount(ListViewSkin.java:149)
at com.sun.javafx.scene.control.skin.ListViewSkin.access$600(ListViewSkin.java:26)
at com.sun.javafx.scene.control.skin.ListViewSkin$12.onChanged(ListViewSkin.java:119)
at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:62)
at com.sun.javafx.collections.ObservableListWrapper.set(ObservableListWrapper.java:196)
at listvieweditingissue.ListViewEditingIssue$1.handle(ListViewEditingIssue.java:44)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:59)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:44)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:27)
at javafx.event.Event.fireEvent(Event.java:156)
at javafx.scene.Node.fireEvent(Node.java:5138)
at javafx.scene.control.Button.fire(Button.java:138)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:166)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:272)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:265)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:55)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:44)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:156)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2341)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2164)
at javafx.scene.Scene$MouseHandler.access$1000(Scene.java:2136)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1095)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1636)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:180)
at com.sun.glass.ui.View.handleMouseEvent(View.java:244)
at com.sun.glass.ui.View.notifyMouse(View.java:496)
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$1$1.run(WinApplication.java:49)
at java.lang.Thread.run(Thread.java:662)
Below codes can be used to re-produce:
------------------------------------------
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.stage.Stage;
/**
*
* @author lianqi.li
*/
public class ListViewEditingIssue extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("ListView Editing Issue");
final Group root = new Group();
final Scene scene = new Scene(root, 500, 400);
final ObservableList<String> listData = FXCollections.observableArrayList(
"red", "blue", "green", "yellow", "gold"
);
final ListView<String> listView = new ListView<String>(listData);
listView.getSelectionModel().select(0);
listView.setTranslateX(10);
listView.setTranslateY(10);
final Button b = new Button("Edit");
b.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
listData.set(listView.getSelectionModel().getSelectedIndex(), "brown");
}
});
b.setLayoutX(140);
b.setLayoutY(300);
root.getChildren().addAll(listView, b);
stage.setScene(scene);
stage.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(final String[] args) {
Application.launch(ListViewEditingIssue.class, args);
}
}
Broken: JavaFX 2.0 beta b34 + JDK 1.6.0_25 + WinXP SP3
Working: JavaFX 2.0 beta b32 + JDK 1.6.0_25 + WinXP SP3
If a ListView is constructed on an ObservableList, say "ol", then, calling
ol.set(int, String) will cause NullPointerException.
Note that this problem only happened with b34, while, everything was fine\
with b32.
How to re-produce:
1. Run the sample app(codes below)
2. Click the <edit> button
3. With b32, you will see the first item in the ListView is changed to "brown"
With b34, nothing happens but you will see below exception
java.lang.NullPointerException
at javafx.scene.control.ListCell$5.invalidated(ListCell.java:131)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:62)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:116)
at javafx.scene.control.ListCell.setListView(ListCell.java:89)
at javafx.scene.control.ListCell.impl_updateListView(ListCell.java:252)
at com.sun.javafx.scene.control.skin.ListViewSkin.updateCellCount(ListViewSkin.java:149)
at com.sun.javafx.scene.control.skin.ListViewSkin.access$600(ListViewSkin.java:26)
at com.sun.javafx.scene.control.skin.ListViewSkin$12.onChanged(ListViewSkin.java:119)
at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:62)
at com.sun.javafx.collections.ObservableListWrapper.set(ObservableListWrapper.java:196)
at listvieweditingissue.ListViewEditingIssue$1.handle(ListViewEditingIssue.java:44)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:59)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:44)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:27)
at javafx.event.Event.fireEvent(Event.java:156)
at javafx.scene.Node.fireEvent(Node.java:5138)
at javafx.scene.control.Button.fire(Button.java:138)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:166)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:272)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:265)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:55)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:44)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:156)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2341)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2164)
at javafx.scene.Scene$MouseHandler.access$1000(Scene.java:2136)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1095)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1636)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:180)
at com.sun.glass.ui.View.handleMouseEvent(View.java:244)
at com.sun.glass.ui.View.notifyMouse(View.java:496)
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$1$1.run(WinApplication.java:49)
at java.lang.Thread.run(Thread.java:662)
Below codes can be used to re-produce:
------------------------------------------
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.stage.Stage;
/**
*
* @author lianqi.li
*/
public class ListViewEditingIssue extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("ListView Editing Issue");
final Group root = new Group();
final Scene scene = new Scene(root, 500, 400);
final ObservableList<String> listData = FXCollections.observableArrayList(
"red", "blue", "green", "yellow", "gold"
);
final ListView<String> listView = new ListView<String>(listData);
listView.getSelectionModel().select(0);
listView.setTranslateX(10);
listView.setTranslateY(10);
final Button b = new Button("Edit");
b.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
listData.set(listView.getSelectionModel().getSelectedIndex(), "brown");
}
});
b.setLayoutX(140);
b.setLayoutY(300);
root.getChildren().addAll(listView, b);
stage.setScene(scene);
stage.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(final String[] args) {
Application.launch(ListViewEditingIssue.class, args);
}
}