• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find duplicate entries before entering the data into JTable

 
sheethal kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any body suggest me how to check for duplicate entries before entering a row into a existing JTable.
thanks in advance
sheethal
 
Purnachand Md
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int v=TableModel.getRowCount();

int row=0;

while(v > k){

if(cmbSku.getSelectedItem().toString().equals(pTable.getValueAt(row,col).toString()) )
{
JOptionPane.showMessageDialog(null, "Item already in Table List", "Warning", JOptionPane.ERROR_MESSAGE);
return;
}
k++;
}
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sheethal kumar wrote:can any body suggest me how to check for duplicate entries before entering a row into a existing JTable.
thanks in advance
sheethal


what you mean by duplicat entries?, is it just a single column (say ID) in a Row or is it all columns?

If it is just a single column in a row, then you can maintain those entries in a hashset and cross check for duplicate entry for each insert.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try putting the data into a Set, but maybe after ten years ( ), you have worked out your own solution.
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You could try putting the data into a Set, but maybe after ten years ( ), you have worked out your own solution.


hmm....i did not get your reply?, can you please explain why we should not use Set and what is the best option here?, 10years?? why we need to wait 10yrs to use HashSet? puzzled
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell was referring to the fact that this thread was started in 2001, making it 10 years old.
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob, sorry i did not relaize it is 10 year old post
 
Campbell Ritchie
Sheriff
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun Chidam wrote:. . . it is 10 year old post
The latest post is now only 16 minutes old
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Arun Chidam wrote:. . . it is 10 year old post
The latest post is now only 16 minutes old


yep, agreed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic