JTable and ArrayList - Java
Формулировка задачи:
Всем Доброе время суток
Условие такое, считать всю информацию с txt файла и вставить в таблицу.
txt такой:
Name<TAB>Capital<TAB>Population
Republic of Poland<TAB>Warsaw<TAB>34500
Chech Republic<TAB>Prague<TAB>9500
Kingdom of Spain <TAB>Madrid<TAB>41599
отступы через Таб
Name Capital Population
Republic of Poland Warsaw 38500
Chech Republic Prague 10500
Kingdom of Spain Madrid 46599
Название столбцов берется тоже с txt файла.
И выделить красным цветом строку в которой населении больше 20 тысяч.
Но проблема в том, что я все написал, но считать с файла и вставить в таблице не могу, долго мучаюсь уже.
Можете помочь с кодом.
Заранее спасибо
Решение задачи: «JTable and ArrayList»
textual
Листинг программы
@Override
@Override
public Class<?> getColumnClass(int columnIndex) {
switch(columnIndex) {
case 0:
case 1:
case 3:
default:
return Integer.class;
}
}
...
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if(data == null)
return null;
switch(columnIndex) {
case 0:
return data.get(rowIndex).getName();
case 1:
return data.get(rowIndex).getCapitol();
case 2:
return data.get(rowIndex).getPopulation();
}
return null;
}