Нужна помощь, как установить ширину столбца в 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();
}
}
Я погуглил и до сих пор не нашел решения.