How to resolve nested column in tableview after up

2019-02-07 14:58发布

问题:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.dispose(NestedTableColumnHeader.java:323)
at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.updateTableColumnHeaders(NestedTableColumn Header.java:265)
at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.checkState(NestedTableColumnHeader.java:51 9)
at com.sun.javafx.scene.control.skin.NestedTableColum nHeader.computePrefHeight(NestedTableColumnHeader. java:401)
at javafx.scene.Parent.prefHeight(Parent.java:918)
at javafx.scene.layout.Region.prefHeight(Region.java: 1438)
at com.sun.javafx.scene.control.skin.TableHeaderRow.c omputePrefHeight(TableHeaderRow.java:344)
at com.sun.javafx.scene.control.skin.TableHeaderRow.c omputeMinHeight(TableHeaderRow.java:339)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.control.SkinBase.computeMinHeight(Ski nBase.java:254)
at javafx.scene.control.Control.computeMinHeight(Cont rol.java:485)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.Region.computeChildMinAreaHeig ht(Region.java:1700)
at javafx.scene.layout.Region.getMaxAreaHeight(Region .java:1981)
at javafx.scene.layout.Region.computeMaxMinAreaHeight (Region.java:1850)
at javafx.scene.layout.HBox.computeMinHeight(HBox.jav a:419)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.AnchorPane.computeHeight(Ancho rPane.java:297)
at javafx.scene.layout.AnchorPane.computeMinHeight(An chorPane.java:246)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.Region.computeChildMinAreaHeig ht(Region.java:1700)
at javafx.scene.layout.Region.getMaxAreaHeight(Region .java:1981)
at javafx.scene.layout.Region.computeMaxMinAreaHeight (Region.java:1850)
at javafx.scene.layout.HBox.computeMinHeight(HBox.jav a:419)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.Region.computeChildMinAreaHeig ht(Region.java:1700)
at javafx.scene.layout.VBox.getAreaHeights(VBox.java: 440)
at javafx.scene.layout.VBox.computeContentHeight(VBox .java:522)
at javafx.scene.layout.VBox.computeMinHeight(VBox.jav a:400)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.Region.computeChildMinAreaHeig ht(Region.java:1700)
at javafx.scene.layout.VBox.getAreaHeights(VBox.java: 440)
at javafx.scene.layout.VBox.computeContentHeight(VBox .java:522)
at javafx.scene.layout.VBox.computeMinHeight(VBox.jav a:400)
at javafx.scene.Parent.minHeight(Parent.java:946)
at javafx.scene.layout.Region.minHeight(Region.java:1 404)
at javafx.scene.layout.Region.computeChildPrefAreaHei ght(Region.java:1765)
at javafx.scene.layout.VBox.getAreaHeights(VBox.java: 446)
at javafx.scene.layout.VBox.computeContentHeight(VBox .java:522)
at javafx.scene.layout.VBox.computePrefHeight(VBox.ja va:421)
at javafx.scene.Parent.prefHeight(Parent.java:918)
at javafx.scene.layout.Region.prefHeight(Region.java: 1438)
at javafx.scene.layout.AnchorPane.computeHeight(Ancho rPane.java:297)
at javafx.scene.layout.AnchorPane.computePrefHeight(A nchorPane.java:254)
at javafx.scene.Parent.prefHeight(Parent.java:918)
at javafx.scene.layout.Region.prefHeight(Region.java: 1438)
at javafx.scene.layout.Region.minHeight(Region.java:1 406)
at com.sun.javafx.scene.control.skin.ScrollPaneSkin.c omputeScrollNodeSize(ScrollPaneSkin.java:917)
at com.sun.javafx.scene.control.skin.ScrollPaneSkin.l ayoutChildren(ScrollPaneSkin.java:791)
at javafx.scene.control.Control.layoutChildren(Contro l.java:574)
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.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:32 0)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:3 49)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Qua ntumToolkit.java:479)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Qua ntumToolkit.java:460)
at com.sun.javafx.tk.quantum.QuantumToolkit$13.run(Qu antumToolkit.java:327)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run( InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Nativ e Method)
at com.sun.glass.ui.win.WinApplication.access$300(Win Application.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApp lication.java:112)
at java.lang.Thread.run(Thread.java:744)

回答1:

This is noted here, will be fixed in the next release.

https://javafx-jira.kenai.com/browse/RT-36052



回答2:

As this problem still isn't really fixed [JavaFX 8u11] & because the need of an account to view the JIRA thread, i will add the current workarround here. This solution works flawlessly for me, but be aware that it is depraced, which means that the method could be removed with the next update suddenly.

@ ryvantage (I would have commented directly, but I still have < 50 reputation):

This link requires a login. – ryvantage Jul 8 at 2:11

With a TableColumn variable like "tableC" you can do following:

tableC.impl_setReorderable(false);

Also described here: How to prevent TableView from doing TableColumn re-order in javaFX 8?