• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to create jtable with rowheader as well as with columnheader

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to create a table where i want to display header in front of each row as well as header above of all column......

i tried many example but i am not getting any code with both column header as well as row header......

some examples are having row header but not having column header.........some are having column header but not having row header..

can anybody help me how to make jtable with row and column header.......please reply,,,,,
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well a column header is created automatically when you add a JTable to a JScrollPane, so I don't understand your problem with that.

> some examples are having row header

So then use that example to add the row header.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Rob said, it is difficult without seeing any code.
I take it you know how to create and use tables. If not you might find this useful http://java.sun.com/docs/books/tutorial/uiswing/components/table.html Notice the section about adding tables to a containers. That might be one of the reasons why you are not seeing the column header.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved this once by simply adding a column at the start of my TableModel, then giving that column a special TableCellRenderer which mimics the look&feel of the table header, and adding a mouse listener to the table to handle clicks on that column.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:I solved this once by simply adding a column at the start of my TableModel, then giving that column a special TableCellRenderer which mimics the look&feel of the table header, and adding a mouse listener to the table to handle clicks on that column.



The feature that this approach lacks is to have the row header not scroll with the rest of the table. Or rather, to scroll up/down with the table but to stay put when scrolling left/right.

For that, typically a one-column table is added to the west side of table's scroll pane via JScrollPane.setRowHeader(). This is reasonably simple so long as the rows of the main table are all the same height.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic