FileDocCategorySizeDatePackage
FileModel.javaAPI DocExample1939Thu Oct 24 20:14:24 BST 2002None

FileModel

public class FileModel extends AbstractTableModel

Fields Summary
String[]
titles
Class[]
types
Object[]
data
Constructors Summary
public FileModel()


     this("."); 
public FileModel(String dir)

    File pwd = new File(dir);
    setFileStats(pwd);
  
Methods Summary
public java.lang.ClassgetColumnClass(int c)

 return types[c]; 
public intgetColumnCount()

 return titles.length; 
public java.lang.StringgetColumnName(int c)

 return titles[c]; 
public intgetRowCount()

 return data.length; 
public java.lang.ObjectgetValueAt(int r, int c)

 return data[r][c]; 
public voidsetFileStats(java.io.File dir)

    String files[] = dir.list();
    data = new Object[files.length][titles.length];

    for (int i=0; i < files.length; i++) {
      File tmp = new File(files[i]);
      data[i][0] = new Boolean(tmp.isDirectory());
      data[i][1] = tmp.getName();
      data[i][2] = new Boolean(tmp.canRead());
      data[i][3] = new Boolean(tmp.canWrite());
      data[i][4] = new Long(tmp.length());
      data[i][5] = new Date(tmp.lastModified());
    }

    // Just in case anyone's listening...
    fireTableDataChanged();