jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes JTable Row Header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Row Header" Watch "JTable Row Header" New topic

JTable Row Header

Sharmila Tankala

Joined: Apr 27, 2004
Posts: 1
Can i have the first column of the jtable as its rowheader
if so can i have an example
thanks in advance
maggie woo
Ranch Hand

Joined: Dec 18, 2003
Posts: 35
My guess is you probably *CAN* by screwing around with it, but this is an interesting question since the JScrollPane accepts a row header (setRowHeader(JViewPort rowheader)), but JTable doesn't support one!
If no one has done it out there already, maybe the following track as a possiblity:
1) modify the column header for your "row header" column so that it is blank and unclickable--maybe a shade darker and "flat" instead of "beveled" which i think is the usual rendering.
2) add a cell renderer for the first column, something like a JButton or JToggleButton with a beveled border, make them uneditable.
3) if you want the user's click on the row header to do something (like "select the row"), then have a mouse listener or something--a JToggleButton might be a nice feature if you wanted to select the row (have it be "pressed" when the row is selected by a mouse click and "armed" when the row is selected in some other manner).
This is pretty advanced stuff I think. Try a google groups search to see if anyone's done it already out there...
And then, maybe post YOUR code up here! hurrah for that!
- maggie
maggie woo
Ranch Hand

Joined: Dec 18, 2003
Posts: 35
oh, just search this forum. here's a link:
I agree. Here's the link: http://aspose.com/file-tools
subject: JTable Row Header
It's not a secret anymore!