0
我試圖創建系統文件瀏覽器,在驅動器目錄中啓動。通過AbstractTableModel不返回驅動器名稱
public class Window {
static class MyFrame extends JFrame implements Constants {
MyFrame() throws HeadlessException {
FileSystemTableModel model = new FileSystemTableModel();
model.setFiles(File.listRoots());
JTable table = new JTable(model);
這裏
public class FileSystemTableModel extends AbstractTableModel implements
Constants {
private File currentDircetory;
private File[] files;
@Override
public Object getValueAt(int arg0, int arg1) {
switch (arg1) {
case 0:
return files[arg0].getName();
case 1:
return files[arg0].length();
case 2:
return new Date(files[arg0].lastModified());
}
return arg1;
}
設定值是我的結果屏幕;我如何顯示驅動器名稱?
你要創建和發佈[小例子程序(http://stackoverflow.com/help/mcve) 。 –