ClassCastException from DoubleStringConverter

Andrew Munn andrew at nmedia.net
Wed Apr 3 02:07:06 UTC 2019


This happens in FX 11.0.2 and 12.  I declare a column for Doubles...

@FXML
private TableColumn<Whatever, Double> myColumn;

When I add this code:
myColumn.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));

I get this exception:

Exception in thread "JavaFX Application Thread" 
java.lang.ClassCastException: class java.lang.Integer cannot be cast to 
class java.lang.Double (java.lang.Integer and java.lang.Double are in 
module java.base of loader 'bootstrap')
        at javafx.base/javafx.util.converter.DoubleStringConverter.toString(DoubleStringConverter.java:35)
        at javafx.controls/javafx.scene.control.cell.CellUtils.getItemText(CellUtils.java:107)
        at javafx.controls/javafx.scene.control.cell.CellUtils.updateItem(CellUtils.java:208)
        at javafx.controls/javafx.scene.control.cell.TextFieldTableCell.updateItem(TextFieldTableCell.java:211)
        at javafx.controls/javafx.scene.control.TableCell.updateItem(TableCell.java:665)
        at javafx.controls/javafx.scene.control.TableCell.indexChanged(TableCell.java:469)
        at javafx.controls/javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:120)
        at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:539)
        at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.<init>(TableRowSkinBase.java:159)
        at javafx.controls/javafx.scene.control.skin.TableRowSkin.<init>(TableRowSkin.java:89)
        at javafx.controls/javafx.scene.control.TableRow.createDefaultSkin(TableRow.java:213)
        at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897)
        at javafx.controls/javafx.scene.control.Control.access$000(Control.java:83)
        at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89)
        at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)
        at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145)
        at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9529)
        at javafx.graphics/javafx.scene.Node.applyCss(Node.java:9616)
        at javafx.controls/javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1715)
        at javafx.controls/javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1692)
        at javafx.controls/javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1801)
        at javafx.controls/javafx.scene.control.skin.VirtualFlow.computeViewportOffset(VirtualFlow.java:2639)
        at javafx.controls/javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1245)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211)
        at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:576)
        at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2482)
        at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:412)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:411)
        at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:438)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:519)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:499)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:492)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:320)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
        at java.base/java.lang.Thread.run(Thread.java:834)


More information about the openjfx-dev mailing list