需要帮助如何设置AbstractTableModel
中的宽度列?我在我的表属性中设置了autoRsizeMode = Off,我正在尝试这个tablePriceList.getColumn(0).setWidth(400);
这个代码在我使用DefaultTableModel
时工作正常,但它在AbstractTableModel
中不起作用,
这是我的AbstractTableModel
班级:
public class ListPriceTableModel extends AbstractTableModel {
private final List<ListPrice> price ;
private final String[] columns ;
public ListPriceTableModel(List<ListPrice> ListPrice){
super();
price = ListPrice ;
columns = new String[]{"Nomor","Kode Voicher","Description","Provider", "Nominal", "Sales Price"};
}
// Number of column of your table
@Override
public int getColumnCount() {
return columns.length ;
}
// Number of row of your table
public int getRowsCount() {
return price.size();
}
// The object to render in a cell
@Override
public Object getValueAt(int row, int col) {
ListPrice club = price.get(row);
switch(col) {
case 0: return club.getNomor();
case 1: return club.getKode_voucher();
case 2: return club.getDescription();
case 3: return club.getNominal();
case 4: return club.getProvider_name();
case 5: return club.getSales_price();
default: return null;
}
}
// Optional, the name of your column
@Override
public String getColumnName(int col) {
return columns[col] ;
}
@Override
public int getRowCount() {
return price.size();
}
}
我有谷歌它仍然没有找到任何解决方案。