/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uas;
//import com.entity.Department;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
*
* @author */
public class DepartmentTableModel extends AbstractTableModel {
String columNames[] = {"DepartmentID", "DepartmentName"};
ArrayList<Department> data;
public DepartmentTableModel()
{
Department r=new Department();
data = r.read();
}
public int getRowCount() {
return data.size();
}
public int getColumnCount() {
return columNames.length;
}
public Object getValueAt(int rowIndex, int columnIndex) {
Department temp = data.get(rowIndex);
if (columnIndex == 0) {
return temp.getDepartmentID();
} else {
return temp.getDepartmentName();
}
}
@Override
public String getColumnName(int col) {
return columNames[col];
}
@Override
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uas;
//import com.entity.Department;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
*
* @author */
public class DepartmentTableModel extends AbstractTableModel {
String columNames[] = {"DepartmentID", "DepartmentName"};
ArrayList<Department> data;
public DepartmentTableModel()
{
Department r=new Department();
data = r.read();
}
public int getRowCount() {
return data.size();
}
public int getColumnCount() {
return columNames.length;
}
public Object getValueAt(int rowIndex, int columnIndex) {
Department temp = data.get(rowIndex);
if (columnIndex == 0) {
return temp.getDepartmentID();
} else {
return temp.getDepartmentName();
}
}
@Override
public String getColumnName(int col) {
return columNames[col];
}
@Override
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
}
Tidak ada komentar:
Posting Komentar