当前位置: 首页> 健康> 母婴 > 在哪里找工作比较真实_如何创建一个网站用来存放东西_线上推广产品_中国网站访问量排行

在哪里找工作比较真实_如何创建一个网站用来存放东西_线上推广产品_中国网站访问量排行

时间:2025/7/20 22:28:30来源:https://blog.csdn.net/zhang168/article/details/146401460 浏览次数:1次
在哪里找工作比较真实_如何创建一个网站用来存放东西_线上推广产品_中国网站访问量排行

JavaFx在执行以下代码后

private void updateValues(IntegerProperty[][] items, int cols, int[][] newValues) {IntStream.range(0, rows).parallel().forEach(row -> {for (int col = 0; col < cols; col++) {items[row][col].setValue(newValues[row][col] / 100);}});
}

 会有以下报错

Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 7436 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:359) at java.base/java.util.ArrayList.get(ArrayList.java:427) at javafx.graphics/javafx.scene.Parent.updateCachedBounds(Parent.java:1704) at javafx.graphics/javafx.scene.Parent.recomputeBounds(Parent.java:1648) at javafx.graphics/javafx.scene.Parent.doComputeGeomBounds(Parent.java:1501) at javafx.graphics/javafx.scene.Parent$1.doComputeGeomBounds(Parent.java:115) at javafx.graphics/com.sun.javafx.scene.ParentHelper.computeGeomBoundsImpl(ParentHelper.java:84) at javafx.graphics/com.sun.javafx.scene.NodeHelper.computeGeomBounds(NodeHelper.java:116) at javafx.graphics/javafx.scene.Node.updateGeomBounds(Node.java:3813)

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot read field "boundsChanged" because "<local11>" is null
    at javafx.graphics/javafx.scene.Parent.updateCachedBounds(Parent.java:1705)
    at javafx.graphics/javafx.scene.Parent.recomputeBounds(Parent.java:1648)
    at javafx.graphics/javafx.scene.Parent.doComputeGeomBounds(Parent.java:1501)
    at javafx.graphics/javafx.scene.Parent$1.doComputeGeomBounds(Parent.java:115)
    at javafx.graphics/com.sun.javafx.scene.ParentHelper.computeGeomBoundsImpl(ParentHelper.java:84)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.computeGeomBounds(NodeHelper.java:116)
    at javafx.graphics/javafx.scene.Node.updateGeomBounds(Node.java:3813)
    at javafx.graphics/javafx.scene.Node.getGeomBounds(Node.java:3775)
    at javafx.graphics/javafx.scene.Node.getLocalBounds(Node.java:3723)
    at javafx.graphics/javafx.scene.Node.updateTxBounds(Node.java:3877)
    at javafx.graphics/javafx.scene.Node.getTransformedBounds(Node.java:3669)
    at javafx.graphics/javafx.scene.Node.updateBounds(Node.java:771)
    at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1835)
    at javafx.graphics/javafx.scene.SubScene.updateBounds(SubScene.java:710)
    at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1833)
    at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1833)
    at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1833)
    at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1833)

 IntegerProperty[][] items 是Box的高度绑定的数组,执行本方法后,Box会自动更新高度,然后代码也是在UI线程中执行的,报错中也看不到任何自定义代码

问题就出在parallel方法上,parallel 是把流转换成一个并行流,本意是为了提升速度的,但用在此处就不合适了,改成普通的循环就好了

    IntStream.range(0, rows).forEach(row -> {
       for (int col = 0; col < cols; col++) {
           items[row][col].setValue(newValues[row][col] / 100);
       }
    });

关键字:在哪里找工作比较真实_如何创建一个网站用来存放东西_线上推广产品_中国网站访问量排行

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: