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.
My Jtable looks like
__________________________________________________ _______
ip | operation | progress bar | rate per second | Layer
__________________________________________________ _______
ip's are comming from the network and i am also getting the operations as ARP REQUEST and UDP.
Now there should be separate row for the ip having different operation. I dont know what to change in my hashtable logic but i think i have to compare according to the operation also. Have a look at my code snippet
Code:
public void recieve(String[] a,int nums,int no_of,String udpval)
{
try
{
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))
{
counter = 1;//counter=counter+1;
rate = pack_siz;
ht.put(ip,counter);
tabModel.addRow(new Object[]{ip,a[0],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(ht.get(ip)));//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))
{
Object o_val = tabModel.getValueAt(u,2);
++counter;//increment the counter by 1
ht.put(ip,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)
{}
}
Any help would be appreciated
So plz help i m running out of time and my teacher wont accept this after the deadline.
Thanks and Regards