Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


unable to display data in JTable at runtime

Posted on 2004-10-25
Medium Priority
Last Modified: 2008-03-03
I did create a JTable on GUI and tried to display data on it.I am getting the data on table but it is not displaying at run time.

The sample code is :

this.TblReport=FillTable(new javax.swing.JTable(),rs);

//this.TblReport is the JTable object created at designe time by using NetBeans IDE.
// rs is a ResultSet with data.

I have all the data in TblReport object, but it is not displaying. what will be the problem?. anyone can help me?.

 public javax.swing.JTable FillTable (javax.swing.JTable table, ResultSet rs) {

return new javax.swing.JTable(rows, columnNames);

//rows and columnNames are data vectors for data and columns of the table.
Question by:tstName
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 37

Expert Comment

ID: 12397994
Better not replacing the JTable but the data of the table's model
LVL 92

Expert Comment

ID: 12398000



 public javax.swing.JTable FillTable (ResultSet rs) {

return new javax.swing.JTable(rows, columnNames);

//rows and columnNames are data vectors for data and columns of the table.
LVL 37

Accepted Solution

zzynx earned 60 total points
ID: 12398089
Try this:

this.TblReport.setModel( getModel(rs) );


public javax.swing.table.DefaultTableModel getModel(ResultSet rs) {

     return new javax.swing.table.DefaultTableModel(rows, columnNames);

Author Comment

ID: 12407615
thank you zzynx, your method is working fine.
LVL 37

Expert Comment

ID: 12408220
Thanks for accepting

>> your method is working fine
Just wondering why you gave it a B then...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question