0

I am printing JTable as below.

MessageFormat header = new MessageFormat("My Header");
MessageFormat footer = new MessageFormat("My Footer {0,number,integer}");
table1.print(JTable.PrintMode.NORMAL, header, footer);

It is working but issue is it splits single table into two parts as my table is having many columns. See Screenshot.

Image 1: Table in my application JSwing Table

Image 2: Print Preview - Table is splitted into two parts. Print Preview

Can anyone please help me in formatting table properly in Print Preview.

Also in description column some text are not appearing as there are many words in that field.

Kaushik
  • 57
  • 5
  • 1
    Maybe something like [this](http://stackoverflow.com/questions/26660448/table-print-does-not-fit-to-page-size/26665276#26665276) can help – MadProgrammer May 01 '15 at 08:39
  • 2
    You could also try using [`JTable#PrintMode.FIT_WIDTH`](http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.PrintMode.html#FIT_WIDTH) or print in landscape mode – MadProgrammer May 01 '15 at 08:41
  • Thanks @MadProgrammer , it worked!!! but still problem is with description field. It is not showing entire description. – Kaushik May 01 '15 at 08:47
  • In the example I linked, one of the solutions is to resize the columns. You could resize the columns to fit the content before printing. Something like [this](http://stackoverflow.com/questions/15126651/how-to-auto-resize-all-columns-of-a-jtable-to-the-same-size/15127241#15127241) for example... – MadProgrammer May 01 '15 at 08:52
  • use JLabels instead of MessageFormat header/footer – mKorbel May 01 '15 at 09:18

1 Answers1

0

TRY FIT_WIDTH INSTEAD OF USING NORMAL.

  • 2
    Hello, please read [Why is it considered inappropriate and unprofessional to type in all capital letters?](https://www.quora.com/Why-is-it-considered-inappropriate-and-unprofessional-to-type-in-all-capital-letters). Thank you. – Eric Aya Apr 22 '22 at 10:39