Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

ProbProblem adding records using AbastractTableModel

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I'm starting to use AbstractTableModel to customize a JTable model. The problem appears when you add a record from a ResultSet to JTable object.
I've managed to insert records, but empty, I need that for every column I can see the data is there.
Leave some code I have been writing ... the method to insert records in JTable is called "insertEmptyRow" (for now).
I need some opinion that can make changes to the code of this method so you can get to see all the data in a record.

Regards (Javier from Argentina )

P / D: Some Code


the above code is called from

Posts: 1104
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javier,
First of all, you should separate the code dealing with JDBC and the GUI code separately. Using the ResultSet directly within the GUI is not a good idea.

As for the table model, I would ask you to first look at the tutorial to understand more about tables and models. Once you get an understanding, you can work with it.
Javier Zalasar
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello :

I was reading the tutorial several times , always work with DefaultTableModel , this class has a " insertRow " method that handles so almost " automatic" load of records in the JTable .
The issue with AbstractTableModel is I do not understand how it works ( I have a habit of investigating from scratch how things work ) and I have some very specific questions.
When I assign a "custom model " ( inheriting from AbstractTableModel ) to a JTable that is what happens internally ?
Obviously the class structure is the same there is a constructor and methods that are overwritten , so I do not understand is that method I call to get the records .
I was thinking an alternative , use the " getValueAt (int rowIndex , int columnIndex )" method but leading the " wrapper " class and calling Getters and Setters of the same methods. But I still have the same problem as I insert in the JTable ?

From already thank you very much for your patience and for answering .
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic