I have the following code:
class Files {
private static String files;
private static String duration;
private static String status;
public Files(String files, String duration, String status) {
this.files = files;
this.duration = duration;
this.status = status;
}
public static String getfiles() {
return files;
}
public static String getduration() {
return duration;
}
public static String getstatus() {
return status;
}
}
Map<Files, String> hmap = new HashMap<Files,String>();
private void AddFiles(String addfile,String addurr,String addstatus, String addpath){
Files f = new Files(addfile, addurr, addstatus);
hmap.put(f, addpath);
}
final JTable table = new JTable();
table.setBounds(26, 27, 664, 274);
table.setModel(new MyTableModel());
So I'm creating a new table and overriding "getValueAt".
class MyTableModel extends AbstractTableModel {
@Override
public int getColumnCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getRowCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {
case 0:
return Files.getfiles();
case 1:
return Files.getduration();
case 2:
return Files.getstatus();
default:
throw new IndexOutOfBoundsException();
}
}
}
Yet I am not able to load the variables from the class "Files" of HashMap into the JTable. Can anybody tell me what I'm doing wrong? I've basically been stuck for 3 days now and would really appreciate some help.