Jtable with ftp files

I want to fill my Jtable with the directorys and files of an ftp server how do i do that?
[96 byte] By [StageHera] at [2007-11-27 1:45:23]
# 1

With a JakartaWrapper you can do it like this:

FTPFile[] children = wrapper.listFiles();

FileTableModel1 model1 = new FileTableModel1(children);

table1 = new JTable(model1);

and than the code for filetablemodel1:

class FileTableModel1 extends AbstractTableModel{

private FTPFile[] data;

private String[] columnNames = {"", "name", "size"};

private Class[] columnClasses = {Icon.class, String.class,Long.class};

public FileTableModel1(FTPFile[] data) {

this.data = data;

}

public int getColumnCount() {

return columnNames.length;

}

public int getRowCount() {

return data.length;

}

public String getColumnName(int col) {

return columnNames[col];

}

public Class getColumnClass(int col) { return columnClasses[col]; }

public Object getValueAt(int row, int col) {

FTPFile file = data[row];

switch( col ){

case 0: return file.isDirectory() ? folder : files;

case 1: return file.getName();

case 2: if (file.getSize()==1024 || file.getSize()==2048 || file.getSize()==3072){

return null;

}else{

return file.getSize();

}

default:

return new Object();

}

}

}

Satanduvel

Satanduvela at 2007-7-12 1:05:42 > top of Java-index,Desktop,Core GUI APIs...
# 2
HeyThx mate 4 so a quick reply i'm testing it out right now. Hopefully it will work
StageHera at 2007-7-12 1:05:42 > top of Java-index,Desktop,Core GUI APIs...
# 3
I get a fault oncase 0: return file.isDirectory() ? folder : files;It doesnt recognise folder and files?
StageHera at 2007-7-12 1:05:42 > top of Java-index,Desktop,Core GUI APIs...
# 4
Hi,folder and files are IconsSo in my program there is a icon for a folder and a icon for a file in the JtableSatanduvel
Satanduvela at 2007-7-12 1:05:42 > top of Java-index,Desktop,Core GUI APIs...
# 5
Hey thx its working. You've earned the duke stars
StageHera at 2007-7-12 1:05:42 > top of Java-index,Desktop,Core GUI APIs...