File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Is it possible to give row names and column names for a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is it possible to give row names and column names for a JTable" Watch "Is it possible to give row names and column names for a JTable" New topic
Author

Is it possible to give row names and column names for a JTable

sum prit
Greenhorn

Joined: Mar 13, 2011
Posts: 14
Sir, i have a little bit of idea about JTable. I do not know whether it is possible to give both the row names and column names in a JTable. I have seen some examples by googling and everywhere i found that while displaying data only column names are given.

I have a database with a table having Temperature, Rainfall and DateTime columns. Now my requirement is to give Temperature, Rainfall name as rows and DateTime a columns and corresponding to a particular DateTime i need to display Temperature and Rainfall values. Is it possible to give?

please provide me some suggestion so that i can continue further.

Thank you in advance. Any help from you will highly be appreciated......
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2215
    
    7
Actually it the JScrollPane that supports both a column header and a row header.

A JTable takes advantage of this by creating a column header component. A JTable does not support a row header component.

So you will need to create a custom row header component. This component could actually be a JTable. The Row Number Table is an example of such a component. It obviously doesn't do what you want it do to, but it should help you in creating your own component.
sum prit
Greenhorn

Joined: Mar 13, 2011
Posts: 14
Thank you Sir for giving me a way to continue. Now i will try something to do and proceed further.....

Thank you once again for your immense help..
Hernan Acosta
Greenhorn

Joined: Mar 15, 2011
Posts: 7

You can use a second table with one column for the row header, and use it like a fixed column. You also can render it with a header kind Look & Feel .

To create columns that don't scroll (the row header), you need to place a second table in the row header view of the JScrollPane. Then when the user scrolls the table vertically, the two tables will remain in sync.
The two tables then need to share their ListSelection Model. That way, when a row in one table is selected, the row in the other table will automatically be selected.


Quidquid latine dictum sit, altum viditur.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to give row names and column names for a JTable