aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to find duplicate entries before entering the data into JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to find duplicate entries before entering the data into JTable" Watch "How to find duplicate entries before entering the data into JTable" New topic
Author

How to find duplicate entries before entering the data into JTable

sheethal kumar
Greenhorn

Joined: Apr 03, 2001
Posts: 2
can any body suggest me how to check for duplicate entries before entering a row into a existing JTable.
thanks in advance
sheethal

sheethal kumar jain
Purnachand Md
Greenhorn

Joined: Jul 12, 2011
Posts: 1
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

Joined: May 08, 2006
Posts: 79
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.


SCJP 1.4, SCWCD 1.4
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
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

Joined: May 08, 2006
Posts: 79
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

Joined: Oct 27, 2005
Posts: 19762
    
  20

Campbell was referring to the fact that this thread was started in 2001, making it 10 years old.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Arun Chidam
Ranch Hand

Joined: May 08, 2006
Posts: 79
Thanks Rob, sorry i did not relaize it is 10 year old post
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Arun Chidam wrote:. . . it is 10 year old post
The latest post is now only 16 minutes old
Arun Chidam
Ranch Hand

Joined: May 08, 2006
Posts: 79
Campbell Ritchie wrote:
Arun Chidam wrote:. . . it is 10 year old post
The latest post is now only 16 minutes old


yep, agreed
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find duplicate entries before entering the data into JTable