?? tablemodle.java
字號:
package supermarket;
import javax.swing.table.*;
import java.util.Vector;
public class TableModle
extends AbstractTableModel {
String []head;
Vector vt;
public TableModle(String []head,Vector vt) {
this.head = head;
this.vt = vt;
}
/**
* Returns the number of columns in the model.
*
* @return the number of columns in the model
* @todo Implement this javax.swing.table.TableModel method
*/
public int getColumnCount() {
return head.length;//列數
}
/**
* Returns the number of rows in the model.
*
* @return the number of rows in the model
* @todo Implement this javax.swing.table.TableModel method
*/
public int getRowCount() {
return vt.size();//行數
}
/**
* Returns the value for the cell at <code>columnIndex</code> and
* <code>rowIndex</code>.
*
* @param rowIndex the row whose value is to be queried
* @param columnIndex the column whose value is to be queried
* @return the value Object at the specified cell
* @todo Implement this javax.swing.table.TableModel method
*/
public Object getValueAt(int rowIndex, int columnIndex) {
return ((Vector)vt.get(rowIndex)).get(columnIndex);//單元格的數據
}
/**
* Returns a default name for the column using spreadsheet conventions:
* A, B, C, ... Z, AA, AB, etc. If <code>column</code> cannot be found,
* returns an empty string.
*
* @param column the column being queried
* @return a string containing the default name of <code>column</code>
*/
public String getColumnName(int column) {
return head[column];
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -