package uts_pbo_2;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
public class MailTable extends AbstractTableModel{
String columNames[] = {"No Surat", "Perihal", "Penerima", "Pengirim",
"Tanggal Kirim", "Tanggal Terima"};
ArrayList data;
public MailTable(String keyword) throws SQLException {
data = DataHandler.searchNo(keyword);
}
public int getRowCount() {
return data.size();
}
public int getColumnCount() {
return columNames.length;
}
@Override
public String getColumnName(int col) {
return columNames[col];
}
public Object getValueAt(int rowIndex, int columnIndex) {
DataHandler temp = (DataHandler) data.get(rowIndex);
if (columnIndex == 0) {
return temp.getNo();
} else if (columnIndex == 1){
return temp.getHal();
} else if (columnIndex == 2){
return temp.getPnrm();
}else if (columnIndex == 3){
return temp.getPkrm();
}else if (columnIndex == 4){
return temp.getTglSurat();
}else {
return temp.getTglTerima();
}
}
@Override
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
}
Tidak ada komentar:
Posting Komentar