• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Urgent: JTable Header position

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Here is my problem. When you write the following code :
MyTableModel mymodel = new MyTableModel();
JTable table = new JTable(mymodel);
JScrollPane scroll = new JScrollPane(table);
the scroll pane gets the table header (Table Column Model) add displays it automatically at the TOP of the scroll pane,orientation is TOP-LEFT --> TOP-RIGHT. This is fine for most cases were a JTable is used. But in some cases were for instance, you want to display data side by side (for comparison, etc ..) it would be usefull to change this default behavior so that the Table header is displayed as Row-Header (TOP-LEFT --> BOTTOM-LEFT) and create a header that will be displayed in the 'normal' place of the header.(The model should understand the new (row,column) requests).
Example :
Here is a Table :
<CODE>
_____________________________________________________
|Surname | First Name | DOB | etc. | ppp | ppp | ppp |
______________________________________________________
xxxx | xxxx | xxx | xxxx | xxx | xxx | xxx |
______________________________________________________
.............
______________________________________________________
xxxx | xxx | xxx | xxx | xxx | XX | XXx |
______________________________________________________
</CODE>
Now, supposing I want to display Parent and Child data , the table would look like :
<CODE>
<PRE>
_____________________________________
| Parent | Child |
_____________________________________
Surname | xxxx | xxxx
_____________________________________
First name | xxx | xxxxx
_____________________________________
DOB | xxx | xxxx
______________________________________
etc. | xx | xxx
_____________________________________
ppp | xxx | xxx
_____________________________________
ppp | xxx | xxx
_____________________________________
ppp | xxx | xxx
_____________________________________
</PRE>
</CODE>
I would like to use the same TableModel(it is still the same data).
My question is, How can I get the Table Header to display (as in the figure). I don't have a proble creating row-header Jtables. The only solution I have at the moment is trying to translation (row, column) between the 2 tables, but I don't think it is the best way !
Any ideas ?
Thanks.
[ September 25, 2003: Message edited by: raphael Bereh ]
[ September 25, 2003: Message edited by: raphael Bereh ]
Christ UBB s*** Just give us some nice HTML - (<PRE> ) . My Table looks nothing like one !
[ September 25, 2003: Message edited by: raphael Bereh ]
 
Bartender
Posts: 9615
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This guy does incredible stuff with Swing: Swing Examples
Check out the Row Header example second from the bottom.
 
raphael Bereh
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Know that url pretty well. Nothing really like what I need to do there.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refrian from using the word URGENT in your post subject. We treat every post on Javaranch with equal importance and using such words will not help your questions get answered any quicker. It's a bit annoying...
    Bookmark Topic Watch Topic
  • New Topic