View Single Post
  #3 (permalink)  
Old 05-15-2008, 12:15 PM
salmanpirzada1 salmanpirzada1 is offline
Member
 
Join Date: May 2008
Posts: 2
salmanpirzada1 is on a distinguished road
No u didnt get me. The problem is something different. Code is runing fine and removing duplicates and showing each ip progress. But now if the same ip has different operation i have to show as a new row in the jtable not taking care of whether the same ip information repeated bcoz i has different operation now. Hope my code is understandable now.

Code:
public void recieve(String[] a,int nums,int no_of,String udpval) { try { operation = a[0]; ip = a[1]; // if ht.get(ip) is return null means counter equal to zero //if(counter==0)//Is this condition working properly ?. if(! ht.containsKey(ip) && ! ht.containsValue(operation)) { counter = 1;//counter=counter+1; rate = pack_siz; ht.put(ip,operation); ht1.put(coun,counter); tabModel.addRow(new Object[]{ip,operation,counter,createBar(counter, counter+" Packets"),rateBar(rate, rate+" Packets"),udpval}); table.addNotify(); framing.repaint(); } else//means ht contains the ip, means the table contains the ip/* && ht.containsValue(a[0])*/) { counter = Integer.parseInt(String.valueOf(ht1.get(coun)));//you need to cast here rate = pack_siz; int row_numb = tabModel.getRowCount(); for(int u=0;u<=row_numb-1;u++) { if(tabModel.getValueAt(u,0).equals(ip) && tabModel.getValueAt(u,1).equals(operation)) { Object o_val = tabModel.getValueAt(u,2); ++counter;//increment the counter by 1 ht.put(ip,operation); ht1.put(coun,counter); tabModel.setValueAt(String.valueOf(counter),u,2); ////////////////////////////////////////// pBar = (JProgressBar)tabModel.getValueAt(u,3); pBar2 = (JProgressBar)tabModel.getValueAt(u,4); if(counter>10) { pBar.setForeground(Color.RED); } else { pBar.setForeground(Color.GREEN); } pBar.setValue(counter); pBar.setString(counter + " Packets");//you can do this in your renderer class pBar2.setValue(rate); pBar2.setString(rate + " Packets"); break; } framing.repaint(); } } } catch(Exception eeee) {} }
Reply With Quote