1

Need help how to set width column in AbstractTableModel?? i am set autoRsizeMode=Off in my table properties and i am trying like this tablePriceList.getColumn(0).setWidth(400);this code working fine when i am using DefaultTableModel but it does'nt work in AbstractTableModel, and here is my AbstractTableModel Class :

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(); 
    }

}

i have google it and still not found any solution.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
syam houng
  • 307
  • 4
  • 14

0 Answers0