• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Help with getting the correct recnum for book seats method

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the table model - FBNTable and myData is an instance of data class. I am having problems with getting the correct recnum. When I click on book seats button , I try to pick up the row selected from the GUI and then do a getRecord to get the record number.
here is some code from the action performed method
int rowSelected = FBNTable.getSelectedRow();
DataInfo di = myData.getRecord(rowSelected);
int recnum = di.getRecordNumber();

The problem is that after I have done a search filter and for eg the GUI may have just 4 records, so rowSelected value is now 3 if my mouse has selected the 3rd record. Now when I press the book seats button, the getRecord method uses a value of 3 for row selected, and is therefore pointing to the wrong record. The 3rd record in the GUI could have been actually the 20th record in the database. So how can I get to the correct record to pick up its recnum. Any help will be much appreciated.
Posts: 17346
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well in your example, how do you know it is the 20th record. Now take that knowledge, whether you know it from your head, our it is in the code, but basically, you have your Data Model for the Table, why couldn't it also include the actual record number. You don't even have to have it display in the table, but you get the selected row, and see what is in the record number for that row. Or have a matching array that only holds record numbers.
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic