• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding JTable  RSS feed

 
tadi raja
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to everyone,
I have a doubt in JTable, i want to hide JTableHeader and i want to display the JTableHeader names as first row of JTable,is it possible ??
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by tadi raja:
Hi to everyone,
I have a doubt in JTable, i want to hide JTableHeader and i want to display the JTableHeader names as first row of JTable,is it possible ??


Instead of wrapping JTable in a JScrollPane and then adding the scroll pane to the container, add the table directly to the container.
Make the table headers as the first row data of your table model.

PS. I have been noticing you are naming your posts "regarding JTable" or "table doubt". If you can give a more apt title like say "hiding table header" it would be helpful for other people who are searching for a similar thread.
 
tadi raja
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to make the table headers as the first row data of your table model ?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same way you are populating the other data in your table.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll lose the ability for any non-text cell renders and editors.

For instance, you can't have your table model return Boolean.class for any column because then there will be a ClassCastException for the header cell.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Prime:
You'll lose the ability for any non-text cell renders and editors.

For instance, you can't have your table model return Boolean.class for any column because then there will be a ClassCastException for the header cell.


True.
But that can still be worked around by checking the row index while returning the renderer component.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!