• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing problem

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day,

I have an interesting question. I'm trying to print out a JTable. If I call the .print() method on the table, it prints the table perfectly.
What I want to do is create my own printing class(which I did). I basically send stuff to my printing class, from there it creates my page that I want to print. If I send the table to my printing class and print it from the overridden print() method, it prints the table out, but without any columns.
Is there something I'm missing here?
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> I have an interesting question.

you have a custom printing class, so, in the absence of any code,
"Is there something I'm missing here?" is not interesting at all.

all that can be done is point you to the tutorial, which you should have visited already,

http://docs.oracle.com/javase/tutorial/uiswing/misc/printtable.html

if your table prints out OK using that code, compare the two to see what's missing/different.
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:> I have an interesting question.

you have a custom printing class, so, in the absence of any code,
"Is there something I'm missing here?" is not interesting at all.

all that can be done is point you to the tutorial, which you should have visited already,

http://docs.oracle.com/javase/tutorial/uiswing/misc/printtable.html

if your table prints out OK using that code, compare the two to see what's missing/different.



Very well then, here is my print() method:



How is THIS print method different from the normal table.print() method? That's the one thing I don't understand.
If I use this method: the print dialog pops up 3 times! It then prints the table(with columns like I want it) first, my custom page second, then the table again.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just copied your code into/replacing print()

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html

had to comment out the for loop (lines 35 to 40), not having the 'other' vector, and it printed out fine
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:Just copied your code into/replacing print()

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html

had to comment out the for loop (lines 35 to 40), not having the 'other' vector, and it printed out fine



Thanks for the reply!

I did what you said, but it still popped up 3 times and printed the table separately. I will try to show you what I want with some screenshots. table1.png is what I want to be on the page, but table2.png is what I'm getting.
table-1.PNG
[Thumbnail for table-1.PNG]
What I want
table-2.PNG
[Thumbnail for table-2.PNG]
What I don't want
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my printout is like table1.png, but with the title printed - centered above the table,
but not part of the table, and it only printed once, when I clicked 'print me'

perhaps you've added the listener multiple times.

[edit]
thought table1.png was attachment1, then the tooltip came up as table2,
so my printout is like the one you don't want.

from the code in the original link, it looks like you're missing this line
(haven't tested it)

 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:
from the code in the original link, it looks like you're missing this line
(haven't tested it)



Dude you're a freaking genius!!! That works like a charm, I just have to move my table down under the header but that is exactly what I want! Thank you so much :)
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic