如何从Abstracttablemodel列中删除逗号

时间:2017-04-07 05:50:31

标签: java swing user-interface abstracttablemodel

public class WebCrmSearchOutputTableModel extends AbstractTableModel 
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Vector iTotalRows = null;

    public WebCrmSearchOutputTableModel() {
        super();
    }

    public String getColumnName(int pColumn)
    {
        String[] colheads;
        colheads = new String[]
             {
                Language.getMessage("TIT0007"), //Channel       
                Language.getMessage("TIT00038"), //Old Loyalty No
                Language.getMessage("TIT00039"),// ULP No
                Language.getMessage("TIT00040"), // First Name  
                Language.getMessage("TIT00041"), // Last Name
                Language.getMessage("TNR036"),//Town/City   
                Language.getMessage("TIT00042"),//DOB
                Language.getMessage("COR0756"),//Mob no     
                Language.getMessage("TIT00043"),// LandLine
                Language.getMessage("COR0747"),//Email      
                Language.getMessage("TS00034"),//Loyalty Points
                Language.getMessage("XE99936"),// Home Store
                Language.getMessage("TNR037"),//Address1    
                Language.getMessage("TNR038"),//Address2    
                Language.getMessage("TIT00045"),//Current Tier
                Language.getMessage("TIT00046"),//Enrollment Date
                Language.getMessage("XE99038"),//Customer Number

                //Start-BNIKA01 for CR in ULP for Mapping State parameter on 12-10-2012
                ""//State
                //End-BNIKA01 for CR in ULP for Mapping State parameter on 12-10-2012


                //START BSASH05- TNS0115 - Redemption of Mobile - GV
                ,""//Blocked
                ,""//Birthday Disc
                ,""//Anniversary Disc
                //END BSASH05- TNS0115 - Redemption of Mobile - GV
            }; 
        return colheads[pColumn];
    }

    public int getColumnCount() 
    {
        //Start-BNIKA01 for CR in ULP for Mapping State parameter on 12-10-2012
        //return 17;
//      return 18;
        //End-BNIKA01 for CR in ULP for Mapping State parameter on 12-10-2012

        //START BSASH05- TNS0115 - Redemption of Mobile - GV
        return 21;
        //END BSASH05- TNS0115 - Redemption of Mobile - GV
    }
    public int getRowCount() 
    {
        return getTotalRows().size();
    }
    public Vector getTotalRows() 
    {
        return iTotalRows;
    }
    public Object getValueAt(int pRow, int pCol) 
    {
        return ((Object[]) getTotalRows().elementAt(pRow))[pCol];
    }
    public void setTotalRows(Vector pTotalRows) 
    {
        iTotalRows = pTotalRows;
    }
}

2 个答案:

答案 0 :(得分:0)

  

实际上来的值不是以逗号分隔,但渲染有一些问题

我怀疑问题在于渲染。渲染器不仅无缘无故地神奇地显示“,”。

问题出在您的getColumnNames(...)方法上。几点:

  1. 每次调用方法时,都不要填充数组中的值。构造类时应加载列名。
  2. 你的Language.getMessage(...)就是问题所在。该方法返回包含列的String。因此,在将值添加到数组之前,需要创建用于从String中删除“,”的包装器方法。

答案 1 :(得分:0)

问题在于渲染 在为渲染进行一些代码更改并使java意识到该列是字符串而不是int之后它开始工作