I have a JTable inside a JScrollPane. After calling my function which should populate the table I can’t see any changes! I’v tried with table.repaint(), model.fireTableDataChanged() and probably some other stuff that I can’t remember anymore – nothing worked. What am I doing wrong??
My function:
public static void fillVodicTable(JTable table){
DefaultTableModel model=new DefaultTableModel(); //also tried (DefaultTableModel)table.getModel();
table.setModel(model);
model.setColumnIdentifiers(new String[]{"Ime", "Priimek", "Epošta", "Datum rojstva", "Licenca", "Jeziki"});
String [] row={"a","b","c","d","e","f"};
model.addRow(row);
}
1) there no reason call for
model.fireTableDataChanged()forDefaultTableModel2) there no reason call for
table.repaint(), is useless3) what’s
for(Jezik j : v.getTuji_jeziki()) row[5]+=", "+j.toString();there could be more than 100% ** of your issues4)
DefaultTableModelworks in all cases, but requierd only update on EDT, in other hands this is common issue for all Swing JComponents together5) for better help sooner edit yout question with a SSCCE
6) EDT == Event Dispatch Thread
7) SSCCE
DefaultTableModel
model.addRow(row);
Short
Self Contained
Correct
Example
then