Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Working with JTable and recordNr confussion

 
Hans ter Wal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yall,
I'm working on the front-end of my URLyBird assignment, for testing purposes I've build a "getAllRecords" method. When I start my client, it gets all the records from the datafile and displays them in a jtable. In my GUI I've got a seperated panel that shows the record details for a record, a user selects from the jtable. In the panel I've got a editable text field that lets the user enter a customer number. When the user presses the book button I want my application to book that record, but how do I know which record to update?
My solution so far is to add the position in the String[][] that the getRecords() method returns and fill my table with. But I don't want to display the record number in my GUI. How can I construct my jtable with data but only show the relevant columns?
This is my contructor for my ClientTableModel that extends the AbstactTableModel

Any ideas would be appriciated,
Best regards,
Hans
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hans,
Ensure your column model and data model have the record number in it. Then simply remove the column from the display. You will still have access to the record number, but the users will not be able to see it directly.
Without giving too much away, here is a snippet that may assist you:

To get the record number, here is a snippet:

How To Use JTables is also a must. It should help answer all of your JTable related questions. I know it did for me
Hope that points you in the right direction!
Cheers,
Jason
 
Hans ter Wal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jason! I knew I was missing something, the columnModel :-)
Hans
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic