Skip to content

Instantly share code, notes, and snippets.

@fanjavaid
Created February 25, 2013 10:35
Show Gist options
  • Save fanjavaid/5029003 to your computer and use it in GitHub Desktop.
Save fanjavaid/5029003 to your computer and use it in GitHub Desktop.
public class ServerData {
private boolean directory;
private String fileName;
private String dateModified;
private String user;
private Long size;
private String permissions;
public boolean isDirectory() {
return directory;
}
public void setDirectory(boolean directory) {
this.directory = directory;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getDateModified() {
return dateModified;
}
public void setDateModified(String dateModified) {
this.dateModified = dateModified;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
public String getPermissions() {
return permissions;
}
public void setPermissions(String permissions) {
this.permissions = permissions;
}
}
public class TabelDataModel extends AbstractTableModel{
private List<ServerData> listServerData;
public TabelDataModel() {
listServerData = new ArrayList<>(0);
}
public void setData(List<ServerData> listServerData) {
this.listServerData = listServerData;
fireTableDataChanged();
}
@Override
public int getRowCount() {
return listServerData.size();
}
@Override
public int getColumnCount() {
return 6;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
switch(columnIndex) {
case 0 :
return listServerData.get(rowIndex).isDirectory();
case 1 :
return listServerData.get(rowIndex).getFileName();
case 2 :
return listServerData.get(rowIndex).getSize();
case 3 :
return listServerData.get(rowIndex).getDateModified();
case 4 :
return listServerData.get(rowIndex).getUser();
case 5 :
return listServerData.get(rowIndex).getPermissions();
default :
return null;
}
}
@Override
public String getColumnName(int column) {
switch(column) {
case 0 :
return "icon";
case 1 :
return "Filename";
case 2 :
return "Size (Byte)";
case 3 :
return "Date Modified";
case 4 :
return "User";
case 5 :
return "Permission";
default :
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment