KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm subclassing JTable and using a DefaultTableModel to model my table data. The following class sets up the JTable, and adds one row to the model. import java.io.File; import java.util.Iterator; import java.util.Vector; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; public class SelectedFileTable extends JTable { Vector<File> SelectedFiles = new Vector<File>(); DefaultTableModel Model = new DefaultTableModel(); TableColumn ColumnName = new TableColumn(); TableColumn ColumnSize = new TableColumn(); TableColumn ColumnRmIcon = new TableColumn(); ImageFilenameFilter Filter = new ImageFilenameFilter(); public SelectedFileTable() { super(); this.setModel(Model); ColumnName.setHeaderValue(new String("Name") ); ColumnName.setMinWidth(200); ColumnSize.setHeaderValue(new String("Size") ); ColumnSize.setMinWidth(50); ColumnSize.setMaxWidth(100); ColumnRmIcon.setHeaderValue(new String("Remove?") ); ColumnRmIcon.setMaxWidth(100); ColumnRmIcon.setResizable(false); this.addColumn(ColumnName); this.addColumn(ColumnSize); this.addColumn(ColumnRmIcon); this.setShowVerticalLines(false); this.setShowHorizontalLines(true); this.setAutoCreateColumnsFromModel(true); this.addFile( new File("C:/temp/cfk.jpg") ); } public void addFile(File file) { System.out.println("FileTable adding: " + file.getName() ); if ( file.isDirectory() ) { for ( File f : file.listFiles(Filter) ) { this.addFile(f); } } else { if ( Filter.accept(file) ) { System.out.println("Accepting file; " + file.getName() ); SelectedFiles.add(file); { String name = file.getName(); Long size = new Long( file.length() ); String tempstr = new String("X"); System.out.println("RowItems before: " +
Tags (comma-separated)
Save Edits
Cancel