customtablemodule.java~3~

来自「java+sql2000企业人力管理系统」· JAVA~3~ 代码 · 共 72 行

JAVA~3~
72
字号
package managersystem;

import javax.swing.table.*;
import java.util.*;
/**
 * <p>Title: 企业人力资源管理系统</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class CustomTableModule
    extends AbstractTableModel {
  Vector data;
  Vector titles;
  public CustomTableModule() {
  }
  public CustomTableModule(Vector data,Vector titles){
    this.data = data;
    this.titles = titles;
  }

  /**
   * 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 titles.size();
  }

  /**
   * 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 data.size()/getColumnCount();
  }

  /**
   * 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 data.get(rowIndex * getColumnCount() +columnIndex);
  }

  public String getColumnName(int columnIndex){
    return (String)titles.get(columnIndex);
  }
  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    data[rowIndex][columnIndex] = (String)aValue;
  }

  public boolean isCellEditable(int rowIndex, int columnIndex) {
    return true;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?