I've searched and seen this question multiple times, and none of the solutions work.
I have an AbstractTableModel
that I've extended and called AccountTableModel
. The code is as such.
import InvAcntItem.Account;
import java.util.LinkedList;
import javax.swing.table.AbstractTableModel;
public class AccountTableModel extends AbstractTableModel
{
LinkedList<Account> dataList;
private String[] columnNames = {"Username", "Password"};
public AccountTableModel()
{
dataList = new LinkedList<>();
}
public void setNewAccounts(LinkedList<Account> inAccs)
{
System.out.println("Syncing local account");
LinkedList<Account> newList = new LinkedList<>();
for(int i = 0; i < inAccs.size(); i++)
newList.add(Account.getDeepCopy(inAccs.get(i)));
System.out.println("done");
this.dataList = newList;
System.out.println("set");
this.fireTableDataChanged();
System.out.println("set");
}
@Override
public int getRowCount()
{
return dataList.size();
}
@Override
public int getColumnCount()
{
return columnNames.length;
}
@Override
public Object getValueAt(int col, int row)
{
System.out.println("GetValueAt!");
Object retObj = null;
Account rowAcc = dataList.get(row);
switch(col)
{
case 0:
{
retObj = rowAcc.user;
}
break;
case 1:
{
retObj = rowAcc.pass;
}
break;
}
return retObj;
}
}
All of the println
statements are executed, yet the UI never updates. I have even gone so far as to create a button that when clicked calls the table models fireDataChanged
function.
It also calls the getValueAt
function and returns good data.
Is there anything else that would keep a table from redrawing?