You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package view ;
import java.util.List ;
import javax.swing.table.AbstractTableModel ;
import domain.Orderstyj ;
public class OrderTableModelmbz extends AbstractTableModel {
//表格列名columnNames
private String [ ] columnNames = { "订单编号" , "用户ID" , "订单时间" } ;
//表格中的内容保存在List<Product>集合中
private List < Orderstyj > orders = null ;
public OrderTableModelmbz ( List < Orderstyj > orders ) {
this . orders = orders ;
}
//返回行数
@Override
public int getRowCount ( ) {
// TODO 自动生成的方法存根
return orders . size ( ) ;
}
//返回列数
@Override
public int getColumnCount ( ) {
// TODO 自动生成的方法存根
return columnNames . length ;
}
//获得某行某列的数据, 而数据保存在对象数组products中
@Override
public Object getValueAt ( int rowIndex , int columnIndex ) {
// TODO 自动生成的方法存根
// 每一行就是一个Product商品对象
Orderstyj o = orders . get ( rowIndex ) ;
switch ( columnIndex ) {
case 0 :
return o . getOrderid ( ) ; // 第一列订单编号
case 1 :
return o . getUserid ( ) ; // 第二列用户ID
case 2 :
return o . getOrderdate ( ) ; // 第三列订单时间
}
return o ;
}
public String getColumnName ( int columnIndex ) {
return columnNames [ columnIndex ] ;
}
}