So I have been trying to use the example from Tutorial and change it so it fits my program. The getColumnValue method returns the object that holds the information that is supposed to be displayed. Is this the way to go or should it rather return the actual String to be displayed. I guess not because that way I would mix the presentation with the data, which I was trying to avoid.
public class IssueTableFormat implements TableFormat<Appointment> {
public int getColumnCount() {
return 6;
}
public String getColumnName(int column) {
if(column == 0) return "Datum";
else if(column == 1) return "Uhrzeit";
else if(column == 2) return "Nummer";
else if(column == 3) return "Name";
else if(column == 4) return "letzte Aktion";
else if(column == 5) return "Kommentar";
throw new IllegalStateException();
}
public Object getColumnValue(Appointment issue, int column) {
if(column == 0) return issue.getDate();
else if(column == 1) return issue.getDate();
else if(column == 2) return issue.getSample();
else if(column == 3) return issue.getSample();
else if(column == 4) return issue.getHistory();
else if(column == 5) return issue.getComment();
throw new IllegalStateException();
}
}
The column 0 and 1 contain a GregorianCalendar object, but I want column 0 to show the date and 1 to show the time.
So I know using cellRenderers can help here.
This is what I tried.
public class DateRenderer extends DefaultTableCellRenderer {
public DateRenderer() { super(); }
public void setValue(Object value) {
GregorianCalendar g =(GregorianCalendar) value;
value=g.get(GregorianCalendar.HOUR);
}
}
But the cell doesnt show anything, what is wrong here?