aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to print JTable with multi-line header? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to print JTable with multi-line header?" Watch "How to print JTable with multi-line header?" New topic
Author

How to print JTable with multi-line header?

Tim Gruentaler
Greenhorn

Joined: Jan 03, 2009
Posts: 12
Hi,

The title says it... I'm trying to print it with myJTable.print(JTable.PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat).
I tried inserting "\n" into the headerFormat string but it didn't work and i have no idea how to do it.

I have googled this problem but all the topics on forums i found remain unanswered.
Anybody knows how to solve this, especially using the core api?

Thanks,

Irmin
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Try wrapping the label inside <html> and </html>, then use <br> for a line break. Swing components recognize a bit of HTML, and for labels that has so far been the easiest way to enter a line break.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tim Gruentaler
Greenhorn

Joined: Jan 03, 2009
Posts: 12
Thanks for the reply, Rob.

I tried the html but it prints out the tags together with the rest of the text...and again in one line. While googling i saw that people enter a new line like this
new MessageFormat("some text \n");
But it seems not to be working in Jtable's print method...

More suggestions would be great.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to print JTable with multi-line header?