从一个JTABLE MODEL中返回的数组,我想删除页数为零的数据,然后PUT到MAP里面,请教高手应该怎么删除?model里面的数据
        private String[] columnNames = {"名称", "页数"};
        private Object[][] data = {
            {"KathySmithSnowboarding", new Integer(5)},
            {"DoGFGFhnDoeRowing", new Integer(0)},
                {"TUHJohnDoeRowing", new Integer(7)},
                {"OPKJJohnDoeRowing", new Integer(0)},}
未完成的代码
 private void TranceData() {        int RowsCount = 0, numRows = tb.getRowCount(),numCols=tb.getColumnCount();
        Object tmp[][] = new Object[numRows][numCols];        for (int i = 0; i < numRows; i++) {
            for (int j = 0; j < numCols; j++) {
                tmp[i][j] = tb.getValueAt(i, j);
                System.out.print("|"+tmp[i][j]);
            }
        }
        
        for (int i = 0; i < numRows; i++) {
            
            if (tb.getValueAt(i, 1) != "0") {
                RowsCount++;
    
            }        }
        
         Object[] objs = new Object[RowsCount];
        for (int j = 0; j < RowsCount; j++) {            Map maps = new HashMap();
            maps.put("内容", );
            maps.put("页数", );
            objs[j] = maps;
        }

解决方案 »

  1.   

    返回数组里?
    可以用JTable里面的deleteRow的方法删除啊
    然后就注意操作的时候剔除已经被删掉的数据就行了
      

  2.   

    这个JTABLE是一直要用的,不能删,只能对返回的数组进行操作
      

  3.   

    终于搞定了,用了最笨的数组复制办法,下次一定要建个LIST模型啊private void TranceData() throws JRException {
            JasperReport jasperReport;
            JasperPrint jasperPrint;        int RowsCount = 0, numRows = tb.getRowCount(),numCols=tb.getColumnCount();
            Object tmp[][] = new Object[numRows][numCols];        for (int i = 0; i < numRows; i++) {
                for (int j = 0; j < numCols; j++) {
                    tmp[i][j] = tb.getValueAt(i, j);
                    //System.out.print("");//("|"+tmp[i][j]);
                }
            }
            
            //System.out.print(tmp.getClass());
            
            
                    for (int i = 0; i < numRows; i++) {
                
                if (tb.getValueAt(i, 1) != "0") {
                    RowsCount++;
            }
            }
            //System.out.println(RowsCount+""+tb.getValueAt(1, 1).getClass());
            Object forMap[][]=new Object[numRows][numCols];
            
            int ci=0,cj=0;
            while(cj<RowsCount)
            {
                
              if  (tmp[ci][1]!="0"){
                forMap[cj][0]=tmp[ci][0];
                forMap[cj][1]=tmp[ci][1];
                cj++;
              }
              
              ci++;
            }
            
            //debug
            if(false){
               // System.out.println(forMap.length);
                for (int i = 0; i <RowsCount; i++) {
                for (int j = 0; j < numCols; j++) {
                                  System.out.print("fromat|"+forMap[i][j]+"|");
                }
            }
            
            }
            
            
            
    ////        
    //        int hi=0;
    //        while (tmp[hi][1]=="0"){
    //        for(int i=hi-1;i<tmp.length;i++){
    //tmp[i][0]=tmp[i+1][0];
    //tmp[i][1]=tmp[i+1][1];
    //
    //        }
    //        //tmp--;
    //        }    
            
            
            Object[] objs = new Object[RowsCount];
            for (int j = 0; j < RowsCount; j++) {            Map maps = new HashMap();
                maps.put("name", forMap[j][0]);
                maps.put("address", forMap[j][1]);
                objs[j] = maps;
            }JRDataSource dataSource = new JRMapArrayDataSource(objs) {};
            jasperReport = JasperCompileManager.compileReport("./reports/report1.jrxml");
            jasperPrint = JasperFillManager.fillReport(jasperReport, null, dataSource);
            //JasperExportManager.exportReportToPdfFile(jasperPrint, "c://1.pdf");
            JasperViewer.viewReport(jasperPrint);