aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to create jtable with rowheader as well as with columnheader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to create jtable with rowheader as well as with columnheader" Watch "how to create jtable with rowheader as well as with columnheader" New topic
Author

how to create jtable with rowheader as well as with columnheader

santosh kimothi
Ranch Hand

Joined: Jun 10, 2009
Posts: 32
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,,,,,


Santosh Kimothi,
Java programmer
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2215
    
    7
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.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10520
    
    9

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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.

bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create jtable with rowheader as well as with columnheader