Results 1 to 2 of 2

Thread: Traversing the rows of a JTable

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Traversing the rows of a JTable

    How can I traverse the rows of a JTable to search it?
    Last edited by x-ice; Mar 15th, 2008 at 07:47 AM.

  2. #2

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Re: Traversing the rows of a JTable

    Problem solved with code that I found on the java swing forum.
    Code:
    DefaultTableModel myTableModel =(DefaultTableModel) myTable.getModel();
    for ( int i = 0 i < myTableModel.getRowCount(); i++){
          String value = (String) myTableModel.getValueAt(i, 2);
         if( value.equals("California"){
              // do whatever you want with the match, e.g. break out of loop or continue
         }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width