开发者社区> 问答> 正文

Caused by: java.lang.ClassCastException?报错

报错信息如下: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javafx.beans.value.ObservableValue at ruiyi.gui.controller.special.AbstractSpecificAnalysisView.lambda$bindDataToJFXTreeTableColumnDT$1(AbstractSpecificAnalysisView.java:106) at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:563) at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:548) at javafx.scene.control.TreeTableCell.updateItem(TreeTableCell.java:635) at javafx.scene.control.TreeTableCell.indexChanged(TreeTableCell.java:457) at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:116) at com.sun.javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:533) at com.sun.javafx.scene.control.skin.TreeTableRowSkin.updateCells(TreeTableRowSkin.java:220) at com.sun.javafx.scene.control.skin.TableRowSkinBase.init(TableRowSkinBase.java:147) at com.sun.javafx.scene.control.skin.TreeTableRowSkin.(TreeTableRowSkin.java:89) at com.jfoenix.skins.JFXTreeTableRowSkin.(JFXTreeTableRowSkin.java:59) at com.jfoenix.controls.JFXTreeTableRow.createDefaultSkin(JFXTreeTableRow.java:45) at javafx.scene.control.Control.impl_processCSS(Control.java:872) at javafx.scene.Node.processCSS(Node.java:9056) at javafx.scene.Node.applyCss(Node.java:9153) at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1964) at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1797) at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1879) at com.sun.javafx.scene.control.skin.VirtualFlow.computeViewportOffset(VirtualFlow.java:2528) at com.sun.javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1189) at javafx.scene.Parent.layout(Parent.java:1087) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Parent.layout(Parent.java:1093) at javafx.scene.Scene.doLayoutPass(Scene.java:552) at javafx.scene.Scene.preferredSize(Scene.java:1646) at javafx.scene.Scene.impl_preferredSize(Scene.java:1720) at javafx.stage.Window$9.invalidated(Window.java:846) at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109) at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144) at javafx.stage.Window.setShowing(Window.java:922) at javafx.stage.Window.show(Window.java:937) at javafx.stage.Stage.show(Stage.java:259) at application.Main.start(Main.java:80) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) 这里的ObservableValue是javafx.beans.value包下的interface 我的代码是这样的: protected void bindDataToJFXTreeTableColumnDT(JFXTreeTableColumn column, String key) { // 数据查找绑定到table view column.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> { if (column.validateValue(param)) return param.getValue().getValue().getValue(key); else return column.getComputedValue(param); }); } 我同事写的代码是这样的 protected void bindDataToJFXTreeTableColumn(JFXTreeTableColumn column, String key) { // 数据查找绑定到table view column.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> { if (column.validateValue(param)) return param.getValue().getValue().getValue(key); else return column.getComputedValue(param); }); } 同事的代码执行不报错,我的报错。

展开
收起
爱吃鱼的程序员 2020-06-08 11:53:33 778 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    写错了一对getset的方法名,

    setDtdistance
    getDtdistance

    写成了

    setDtistance
    getDtistance
    2020-06-08 11:53:45
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载