This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable question

 
Vijay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody give me an idea of how to go about creating a table like shown below:
_______________________________________________
| column1 | column2 | column 3| Column4 |
_______________________________________________
| **** This row has some string info in it ***|
________________________________________________
| value1 | value2 | value3 | value4 |
________________________________________________
| valuei | value j | valuek | valuez |
_________________________________________________

I need to add that line of text in between the header and the content.
How to go about it ? Should that line be a part of JTableHeader or
should I need to span over the cells of the content ?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Jet Airways" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

It would be *a lot* easier just to put a string above the table headers... is there any really special reason to put it below the headers?

Thanks! and welcome to the JavaRanch!
[ March 18, 2004: Message edited by: Nathan Pruett ]
 
Vijay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-------
Quote:
It would be *a lot* easier just to put a string above the table headers...
is there any really special reason to put it below the headers?
------
Thanks for ur response. Yes, a JLabel would just suffice in ur case.
But I need to display an info like " No records are available for this
table" when there are no rows. Now, again I can do a setPreferredViewPortSize() of the JTable and add a JLabel under the JTable.
But I have atleast 50 tables in my code. And I dont want to goto every place and add those lines of code. Instead I want to generalize and put
my string info in my "generalized" MyJTable or MyHeaderCellRenderer,etc
(which extends JTable, TableCellRenderer,etc)
well, after some googling, I was able to get some hint. Can someone ,now, have a look into it and help me out.
This one is for cell spanning:
http://www.codeguru.com/java/articles/139.shtml
This one can be referred for placing the String in Header ( I prefer it to be here)
http://www.codeguru.com/java/articles/124.shtml
Hoping for a reply (suggestion/code snippet) from JGurus!. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic