Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable help needed.  RSS feed

 
Kamlesh Sangani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I m using JTable to dsisplay data. I m extending AbstractTableModel.
But I dont know how to set columnheading n data in table?
In class i m declaring 2D array for column headnings. but which method i should call to make these headning appear on JTable?
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to override "String getColumnName (int column)" in your implementation of the table model to return the correct column name. As AbstractTableModel does not do any data or header storage, you need to know where the headers are and return them appropriately from this method.
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it just occurred to me that you need to wrap the jTable into a JScrollPane to view the heading, so if jt is the handle to your JTable object and jp is the JPanel on which you want to place it, use:
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!