B4J Question (SOLVED) Cast error fill Tableview

Swissmade

Well-Known Member
Licensed User
Longtime User
I wondering what I'm doing wrong
I have a SQLite DB and fill this with data all good then if it is filled I read the data and like to put this in a TableView.

Filling Table:
Private Sub FillTable As ResumableSub
    Dim PathToSearch As String
    Dim FileName As String
    If modFunctions.Linux = True Then
        PathToSearch = "/home/pi5/Audio-Demucs/"
    Else
        PathToSearch = "H:\Jamulus Audio\Web\Audio\Audio-Demucs\"
    End If

    Wait For (GetTheSongs(PathToSearch)) Complete (SongList As List)
    Dim SongCounter As Int
    Dim mp3 As JavaObject
    For SongCounter = 0 To SongList.Size -1
        FileName = SongList.Get(SongCounter)
        If File.IsDirectory(FileName, "") = False Then
            Wait For(LoadMp3File(FileName)) Complete (MP3File As JavaObject)
            mp3 = MP3File
            If mp3 <> Null Then
                Dim ID2 As Object = mp3.RunMethod("hasId3v2Tag", Null)
                If ID2 = True Then
                    Dim ID3v2Tag As JavaObject = mp3.RunMethod("getId3v2Tag", Null)
                    Dim Track As String = ID3v2Tag.RunMethod("getTrack", Null)
                    Dim Artist As String = ID3v2Tag.RunMethod("getArtist", Null)
                    Dim SongName As String = ID3v2Tag.RunMethod("getTitle", Null)
                    Dim Album As String = ID3v2Tag.RunMethod("getAlbum", Null)
                    Dim Year As String = ID3v2Tag.RunMethod("getYear", Null)
                    Dim Genre As String = ID3v2Tag.RunMethod("getGenreDescription", Null)
                    Dim Lyrics As String = ID3v2Tag.RunMethod("getLyrics", Null)
                    Wait For (modSQLITE.WriteSong(SongName, Artist, Genre, Lyrics, FileName)) Complete (RetValue As Boolean)
                End If
            End If
        Else
            Log("Is Dir " & FileName)
        End If
    Next
    Wait For (FillAudioTable) Complete (RetValue As Boolean) 'here start the tableview filling
    Return True
End Sub

Tableview like to be fiilled

Fill Tableview:
Private Sub FillAudioTable As ResumableSub
    Dim SQLite As SQL
    Dim strSQL As String
    Dim RS As ResultSet
    Try
        SQLite.InitializeSQLite(File.DirApp & "/JamulusAudio/", "JamulusAudioDB.db", False)
        strSQL = "SELECT * FROM Song;"

        Dim SenderFilter As Object = SQLite.ExecQueryAsync("SQL", strSQL, Null)
        Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, RS As ResultSet)
        If Success Then
            Dim ID As String
            Dim SongName As String
            Dim SongArtist As String
            Dim SongGenre As String
            Dim Lyrics As String
            Dim SongPath As String
            Do While RS.NextRow = True
                ID = RS.GetString("ID")
                SongName = RS.GetString("SongName")
                SongArtist = RS.GetString("SongArtist")
                SongGenre = RS.GetString("SongGenre")
                Lyrics = RS.GetString("Lyrics")
                SongPath = RS.GetString("SongPath")
                tblAudioTable.As(TableView).Items.AddAll(Array As String(ID , SongName, SongArtist, SongGenre, Lyrics, SongPath)) 'Not any error here
            Loop
            RS.Close
        Else
            Log(LastException)
        End If
        SQLite.Close
        SQLite = Null
    Catch
        Log(LastException.Message) 'No error message
        Return False
    End Try
    Return True 'Here I get the Cast error see below and the Tableview is not filled.
Waiting for debugger to connect...
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
    at anywheresoftware.b4j.objects.TableViewWrapper$MyCellValueFactory.call(TableViewWrapper.java:228)
    at anywheresoftware.b4j.objects.TableViewWrapper$MyCellValueFactory.call(TableViewWrapper.java:1)
    at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:578)
    at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:563)
    at javafx.scene.control.TableCell.updateItem(TableCell.java:644)
    at javafx.scene.control.TableCell.indexChanged(TableCell.java:468)
    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.TableRowSkinBase.init(TableRowSkinBase.java:147)
    at com.sun.javafx.scene.control.skin.TableRowSkin.<init>(TableRowSkin.java:64)
    at javafx.scene.control.TableRow.createDefaultSkin(TableRow.java:212)
    at javafx.scene.control.Control.impl_processCSS(Control.java:872)
    at javafx.scene.Node.processCSS(Node.java:9063)
    at javafx.scene.Node.applyCss(Node.java:9160)
    at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1965)
    at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1797)
    at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1880)
    at com.sun.javafx.scene.control.skin.VirtualFlow.computeViewportOffset(VirtualFlow.java:2529)
    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.Scene.doLayoutPass(Scene.java:552)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2400)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:402)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:401)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:428)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:562)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:542)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:535)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:341)
    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$4(WinApplication.java:185)
    at java.lang.Thread.run(Thread.java:750)

End Sub

Any help can be nice Thanks
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Try changing your Array parameter to an Object instead of a String and see if that fixes it.
Yes have done this thanks for your input
Possibly change AddAll to just Add as well
Stupid of me that I have not think of.
Maybe to late to code or something had to sleep.

Problem Solved
Many thanks for the hint.
 
Upvote 0
Top