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 JTable question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable question" Watch "JTable question" New topic
Author

JTable question

Vijay
Greenhorn

Joined: Mar 05, 2004
Posts: 5
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

Joined: Oct 18, 2000
Posts: 4121

"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 ]

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Vijay
Greenhorn

Joined: Mar 05, 2004
Posts: 5
-------
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable question
 
Similar Threads
SimpleTags + tagdependent body content
Is it enough to study I/O from K and B for the SCJP
Displaying gifs...
Jtextarea read line by line
three column, two column width is fixed, one is relative to 100%