Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Java - Swing, Search a JTable

x-ice

New member
Joined
Mar 17, 2004
Messages
671
Code:
int rows = ((DefaultTableModel)youTable.getModel()).getRowCount();
int col = 0;

for(int i=0;i<rows;i++)
{
     String value = (String)((DefaultTableModel)yourTable.getModel()).getValueAt(i, col);
     //If the item is already in the table
     if(value.equals("whatever")
     {
           //Do something
     }
}
 
Top