我现在的是想做的是Vector 对象的数据添加---> HashSet---->HashSet 数据添加到表格HashSet  hashLog = new  HashSet();  
        Vector newTempR=new Vector(); 
        if(rows > 0)
        {
            for(int i= 0; i < rows ; i++)
            {   
                //表格列的时间 转换成 "2008051915" 格式的时间字符串
                String celltime = ParseStringTime((String)this.tempLog.getValueAt(i,1));
                if((celltime.compareTo(timefrom) >= 0)  && (celltime.compareTo(timeto) <= 0))
                {
                    //System.out.println("在中间!");
                    //数据在这个范围内,先把数据放到临时表格内,处理完以后则将数据在放回到表格中显示出来                   
                    String  type = (String)this.tempLog.getValueAt(i,0);
                    String  time = (String)this.tempLog.getValueAt(i,1);
                    String  sponsor = (String)this.tempLog.getValueAt(i,2);
                    String  operate = (String)this.tempLog.getValueAt(i,3);
                    String  result = (String)this.tempLog.getValueAt(i,4);
                    newTempR.add(type);
                    newTempR.add(time);
                    newTempR.add(sponsor);
                    newTempR.add(operate);                    
                    newTempR.add(result);                     
                    hashLog.add(newTempR);
                }                
            }             
            this.ClearLogTable();
            Iterator itLog = hashLog.iterator();   
            while(itLog.hasNext())
            {   
                //System.out.println(itLog.next());
                tempLog.addRow((Vector)itLog.next());               
            }             
        } 现在表格中的数据都是同一个数据,大家指点下是什么原因

解决方案 »

  1.   


    可能是newTempR的问题吧
    你试试把Vector newTempR=new Vector();
      放在FOR循环内部(如):
     if((celltime.compareTo(timefrom) >= 0)  && (celltime.compareTo(timeto)  <= 0)) 
                    { 
                          Vector newTempR=new Vector();  
      

  2.   

    HashSet  hashLog = new  HashSet();   
            if(rows > 0) 
            { 
                for(int i= 0; i  < rows ; i++) 
                {    
                  Vector newTempR=new Vector();
                    //表格列的时间 转换成 "2008051915" 格式的时间字符串 
                    String celltime = ParseStringTime((String)this.tempLog.getValueAt(i,1)); 
                    if((celltime.compareTo(timefrom) >= 0)  && (celltime.compareTo(timeto)  <= 0)) 
                    { 
                        //System.out.println("在中间!"); 
                        //数据在这个范围内,先把数据放到临时表格内,处理完以后则将数据在放回到表格中显示出来                    
                        String  type = (String)this.tempLog.getValueAt(i,0); 
                        String  time = (String)this.tempLog.getValueAt(i,1); 
                        String  sponsor = (String)this.tempLog.getValueAt(i,2); 
                        String  operate = (String)this.tempLog.getValueAt(i,3); 
                        String  result = (String)this.tempLog.getValueAt(i,4); 
                        newTempR.add(type); 
                        newTempR.add(time); 
                        newTempR.add(sponsor); 
                        newTempR.add(operate);                     
                        newTempR.add(result);                      
                        hashLog.add(newTempR); 
                    }                 
                }              
                this.ClearLogTable(); 
                Iterator itLog = hashLog.iterator();    
                while(itLog.hasNext()) 
                {    
                    //System.out.println(itLog.next()); 
                    tempLog.addRow((Vector)itLog.next());                
                }              
            } 
    下面这句话应该放到循环中
    Vector newTempR=new Vector();
      

  3.   

      Vector newTempR=new Vector();  //这个写在循环内部!!!没循环一次,实例化一次!