B4J Question TableView duplication or records and returning NULL Pointer Error

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I have a tableview which I am loading from a file what I am updating , then clear the tableview and load the updated version.

I get to a point where I get a Null pointer exception normally around 100 records. Then the tableview does not update any more records even though the file is updated. But i also see something else. Somehow some of the records are duplicated and if I click on them it selects all the duplicates as one record. as seen in the pic below.

Another thing I find is that all labels that were updating on the window also do not update however the buttons do work and keeps updating the database. I also took out the scroll to end just in case that was a problem but it still did the same.

If anyone has any ideas, I would appreciate any comments. Thank you.

1590441434840.png

This is the error

records 101
scroll to end
java.lang.NullPointerException
at javafx.controls/javafx.scene.control.skin.TableCellSkin.tableColumnProperty(TableCellSkin.java:97)
at javafx.controls/javafx.scene.control.skin.TableCellSkinBase.getTableColumn(TableCellSkinBase.java:123)
at javafx.controls/javafx.scene.control.skin.TableCellSkinBase.dispose(TableCellSkinBase.java:136)
at javafx.controls/javafx.scene.control.skin.TableCellSkin.dispose(TableCellSkin.java:88)
at javafx.controls/javafx.scene.control.Control$2.invalidated(Control.java:267)
at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.graphics/javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
at javafx.controls/javafx.scene.control.Control$2.set(Control.java:250)
at javafx.controls/javafx.scene.control.Control$2.set(Control.java:233)
at javafx.controls/javafx.scene.control.Control.setSkin(Control.java:230)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.recreateCells(TableRowSkinBase.java:715)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:505)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.checkState(TableRowSkinBase.java:649)
at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.computePrefHeight(TableRowSkinBase.java:588)
at javafx.controls/javafx.scene.control.Control.computePrefHeight(Control.java:570)
at javafx.graphics/javafx.scene.Parent.prefHeight(Parent.java:1037)
at javafx.graphics/javafx.scene.layout.Region.prefHeight(Region.java:1559)
at javafx.controls/javafx.scene.control.skin.VirtualFlow.resizeCellSize(VirtualFlow.java:1863)
at javafx.controls/javafx.scene.control.skin.VirtualFlow.addLeadingCells(VirtualFlow.java:1948)
at javafx.controls/javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1250)
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.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)

To Load the table I use the following code

B4X:
Sub viewRecords
    TableRecords.Items.Clear

    PaneView.Visible=True

    DBUtils.ExecuteTableView(sql1,"select game_id, no1, no2,no5,no10,no2x,no4x,Chance, Multiplyer,CashPrize from game",Null,0,TableRecords)

    TableRecords.SetColumns(Array As String("Time","1","2","5","10","2x","4x","Chance","X","Cash Prize"))
    TableRecords.SetColumnWidth(0,150)
    TableRecords.SetColumnWidth(1,40)
    TableRecords.SetColumnWidth(2,40)
    TableRecords.SetColumnWidth(3,40)
    TableRecords.SetColumnWidth(4,40)
    TableRecords.SetColumnWidth(5,40)
    TableRecords.SetColumnWidth(5,40)
    TableRecords.SetColumnWidth(6,40)
    TableRecords.SetColumnWidth(7,70)
    TableRecords.SetColumnWidth(8,50)
    TableRecords.SetColumnWidth(9,100)

   Log("records "&TableRecords.Items.Size)
    Try
    TableRecords.ScrollTo(TableRecords.Items.Size-1)
    
    Catch
        Log("error scroll to end")
        End Try

    For Each row() As String In TableRecords.items
        row(0)  = DateTime.date(row(0)) & "-" & DateTime.time(row(0))
    Next

End Sub
 
Last edited:
Top