📄 downloadtablemodel.java
字号:
/*
* Copyright 2007 JavaAtWork All rights reserved.
* Use is subject to license terms.
*/
package com.javaatwork.mydownloader;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import com.javaatwork.mydownloader.utils.LocaleManager;
/**
* Class for showing the contents in the table.
*
* @author Johannes Postma
*/
public class DownloadTableModel extends AbstractTableModel {
private static final long serialVersionUID = 3179596630550679418L;
private String[] columnNames = new String[1];
private List files = null;
/**
* Creates a new DownloadTableModel.
*
* @param files To files to show.
*/
public DownloadTableModel(List files) {
this.files = files;
columnNames[0] = LocaleManager.getInstance().getString("filename");
}
/**
* Returns the number of columns.
*
* @return The number of columns.
*/
public int getColumnCount() {
return columnNames.length;
}
/**
* Returns the number of rows.
*
* @return The number of rows.
*/
public int getRowCount() {
return files.size();
}
/**
* Returns the column name.
*
* @param col The particular column.
* @return The column name.
*/
public String getColumnName(int col) {
return columnNames[col];
}
/**
* Returns the object of a cell in a table.
*
* @param row The row.
* @param col The column.
* @return The object to be displayed.
*/
public Object getValueAt(int row, int col) {
return (DownloadFile) files.get(row);
}
/**
* Returns the class of a column. This class is needed to
* determine the celleditor.
*
* @param col The column.
* @return The class.
*/
public Class getColumnClass(int col) {
return getValueAt(0, col).getClass();
}
/**
* Returns true if a cell is editable.
*
* @param row The row.
* @param col The column.
* @return True if a cell is editable.
*/
public boolean isCellEditable(int row, int col) {
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -