This happened with JDK 8 Early Access Build b129.
When the TableView has a fixed cell size, (the value doesn't matter I've tested 17 and 500), a NullPointerException will be thrown when a TableColumn is dragged and dropped on another to change the order of columns.
This is the output:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.TableCellSkinBase.layoutChildren(TableCellSkinBase.java:151)
at javafx.scene.control.Control.layoutChildren(Control.java:574)
at javafx.scene.control.TableCell.layoutChildren(TableCell.java:641)
at javafx.scene.Parent.layout(Parent.java:1076)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Scene.doLayoutPass(Scene.java:576)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2386)
at com.sun.javafx.tk.Toolkit$3.run(Toolkit.java:322)
at com.sun.javafx.tk.Toolkit$3.run(Toolkit.java:320)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:320)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:349)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:479)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
at com.sun.javafx.tk.quantum.QuantumToolkit$13.run(QuantumToolkit.java:327)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.access$200(GtkApplication.java:48)
at com.sun.glass.ui.gtk.GtkApplication$6$1.run(GtkApplication.java:149)
at java.lang.Thread.run(Thread.java:744)
The Code:
public class Main extends Application {
public void start(Stage primaryStage) throws Exception
{ BorderPane content = new BorderPane(); TableView<Item> table = new TableView<Item>(getTableData()); table.setFixedCellSize(500); TableColumn<Item, String> col1 = new TableColumn<Item, String>("col1"); TableColumn<Item, String> col2 = new TableColumn<Item, String>("col2"); TableColumn<Item, String> col3 = new TableColumn<Item, String>("col3"); TableColumn<Item, String> col4 = new TableColumn<Item, String>("col4"); col1.setCellValueFactory(new PropertyValueFactory<Item, String>("col1")); col2.setCellValueFactory(new PropertyValueFactory<Item, String>("col2")); col3.setCellValueFactory(new PropertyValueFactory<Item, String>("col3")); col4.setCellValueFactory(new PropertyValueFactory<Item, String>("col4")); table.getColumns().addAll(col1, col2, col3, col4); table.setStyle("-fx-font-size: 10px;"); content.setCenter(table); primaryStage.setScene(new Scene(content)); primaryStage.show(); }
private static ObservableList<Item> getTableData()
{ return FXCollections.observableArrayList( (new Item("val1", "val2", Integer.toString(new Integer(3)), Boolean.toString(new Boolean(true)))), new Item("val4", "val5", Integer.toString(new Integer(6)), Boolean.toString(new Boolean(false)))); }
public static void main(String[] args)
{ launch(args); }
}
public class Item {
private SimpleStringProperty m_col1;
private SimpleStringProperty m_col2;
private SimpleStringProperty m_col3;
private SimpleStringProperty m_col4;
public Item(String col1, String col2, String col3, String col4)
{ m_col1 = new SimpleStringProperty(col1); m_col2 = new SimpleStringProperty(col2); m_col3 = new SimpleStringProperty(col3); m_col4 = new SimpleStringProperty(col4); }
public String getCol1()
{ return m_col1.getValue(); }
public String getCol2()
{ return m_col2.getValue(); }
public String getCol3()
{ return m_col3.getValue(); }
public String getCol4()
{ return m_col4.getValue(); }
public SimpleStringProperty getProperty(int columnIdex) {
switch(columnIdex)
{ case 0: return m_col1; case 1: return m_col2; case 2: return m_col3; case 3: return m_col4; default : return m_col1; }
}
When the TableView has a fixed cell size, (the value doesn't matter I've tested 17 and 500), a NullPointerException will be thrown when a TableColumn is dragged and dropped on another to change the order of columns.
This is the output:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.TableCellSkinBase.layoutChildren(TableCellSkinBase.java:151)
at javafx.scene.control.Control.layoutChildren(Control.java:574)
at javafx.scene.control.TableCell.layoutChildren(TableCell.java:641)
at javafx.scene.Parent.layout(Parent.java:1076)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Parent.layout(Parent.java:1082)
at javafx.scene.Scene.doLayoutPass(Scene.java:576)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2386)
at com.sun.javafx.tk.Toolkit$3.run(Toolkit.java:322)
at com.sun.javafx.tk.Toolkit$3.run(Toolkit.java:320)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:320)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:349)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:479)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
at com.sun.javafx.tk.quantum.QuantumToolkit$13.run(QuantumToolkit.java:327)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.access$200(GtkApplication.java:48)
at com.sun.glass.ui.gtk.GtkApplication$6$1.run(GtkApplication.java:149)
at java.lang.Thread.run(Thread.java:744)
The Code:
public class Main extends Application {
public void start(Stage primaryStage) throws Exception
{ BorderPane content = new BorderPane(); TableView<Item> table = new TableView<Item>(getTableData()); table.setFixedCellSize(500); TableColumn<Item, String> col1 = new TableColumn<Item, String>("col1"); TableColumn<Item, String> col2 = new TableColumn<Item, String>("col2"); TableColumn<Item, String> col3 = new TableColumn<Item, String>("col3"); TableColumn<Item, String> col4 = new TableColumn<Item, String>("col4"); col1.setCellValueFactory(new PropertyValueFactory<Item, String>("col1")); col2.setCellValueFactory(new PropertyValueFactory<Item, String>("col2")); col3.setCellValueFactory(new PropertyValueFactory<Item, String>("col3")); col4.setCellValueFactory(new PropertyValueFactory<Item, String>("col4")); table.getColumns().addAll(col1, col2, col3, col4); table.setStyle("-fx-font-size: 10px;"); content.setCenter(table); primaryStage.setScene(new Scene(content)); primaryStage.show(); }
private static ObservableList<Item> getTableData()
{ return FXCollections.observableArrayList( (new Item("val1", "val2", Integer.toString(new Integer(3)), Boolean.toString(new Boolean(true)))), new Item("val4", "val5", Integer.toString(new Integer(6)), Boolean.toString(new Boolean(false)))); }
public static void main(String[] args)
{ launch(args); }
}
public class Item {
private SimpleStringProperty m_col1;
private SimpleStringProperty m_col2;
private SimpleStringProperty m_col3;
private SimpleStringProperty m_col4;
public Item(String col1, String col2, String col3, String col4)
{ m_col1 = new SimpleStringProperty(col1); m_col2 = new SimpleStringProperty(col2); m_col3 = new SimpleStringProperty(col3); m_col4 = new SimpleStringProperty(col4); }
public String getCol1()
{ return m_col1.getValue(); }
public String getCol2()
{ return m_col2.getValue(); }
public String getCol3()
{ return m_col3.getValue(); }
public String getCol4()
{ return m_col4.getValue(); }
public SimpleStringProperty getProperty(int columnIdex) {
switch(columnIdex)
{ case 0: return m_col1; case 1: return m_col2; case 2: return m_col3; case 3: return m_col4; default : return m_col1; }
}