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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 19557
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print JTable with multi-line header?
 
Similar Threads
Printing an array of Swing components
How to print more than one line through MessageFormat()
Printing more than one line with MessageFormat()
headerFormat font size problem
JTable printing . . .