This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ProbProblem adding records using AbastractTableModel  RSS feed

 
Javier Zalasar
Greenhorn
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

MyFirstModel:



the above code is called from


 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE 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
Greenhorn
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 .
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!