1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
private class SimplePlaylistModel extends DefaultTableModel implements TableCellRenderer
{
private static final long serialVersionUID =4938716701048228229L;
private Vector<MediaFile> vdata;
{
vdata = new Vector<MediaFile>();
}
public Component getTableCellRendererComponent(JTable table,
Object val, boolean selected, boolean hasFocus, int row, int col) { ... }
public Class<?> getColumnClass(int col) {
return String.class;
}
public int getColumnCount() {
return 2;
}
public String getColumnName(int col) {
switch (col)
{
case 0 : return "Fichier";
case 1 : return "Localisation";
default : return "???";
}
}
public int getRowCount() {
if (vdata != null)
return vdata.size();
else
return 0;
}
public void addRow(MediaFile mf)
{
Vector<String> v = new Vector<String>();
v.addElement(mf.getName());
v.addElement(mf.getPath());
vdata.addElement(mf);
super.addRow(v);
this.fireTableRowsInserted(0, getRowCount()); // ici ça ne réactualise pas :cry:
}
public void clear()
{
vdata.clear();
fireTableRowsDeleted(0, getRowCount());
}
public Object getValueAt(int row, int col) {
try
{
MediaFile mf = vdata.elementAt(row);
if (mf instanceof AudioMediaFile)
{
AudioMediaFile amf = (AudioMediaFile) mf;
switch (col)
{
case 0 : return amf.getName();
case 1 : return amf.getPath();
default : return "???";
}
}
}
catch (Exception e){}
return "???";
} |
Partager