Skip to content
Advertisement

Put firebase data in a JTable

I am struggling to put some firebase data into a jtable in java swing. As seen in photo I’ve been able to retrieve the data from firebase but for some reason the data won’t be displayed in the JTable field(table1) I looks like the getID(), getName()… methods didn’t get any value, since I tried to print row[i] to see if there is any value.

There is a screenshot of the actual program

Could any of you tell what’s the problem?

JavaScript

Thanks in advance!

Advertisement

Answer

Have you defined the table columns with lines like these?

JavaScript

Also, the method setModel should be called after the for:

JavaScript

EDIT: Analyzing in more detail, I also verify that you have 7 fields but your array has only space for 6. In this line row [6] = casesList.getRisk (); throws an exception at runtime. Expand the size of your array to solve this. Object[] row = new Object[7];

To display the column names it is convenient to add your table to a scroll panel.

JavaScript

This works for me:

JavaScript
Advertisement