This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent: JTable Header position

 
raphael Bereh
Ranch Hand
Posts: 79
  • 0
  • 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 ]
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • 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
  • 0
  • 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.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • 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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic