• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Printing Question

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an object which implements Printable and can be drawn on any Graphics2D (including the one you can get from the Java printing API).
This is the print method

But when I launched the printing, nothing is printed.(Page is white)
Q) How to implement the print method to print the object
Thank you
Garandi
[ May 05, 2003: Message edited by: Garandi Garandi ]
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U have to write the code that u want to print inside the print method. Say for u have some squares drawing in the Paint method. Same code u have to write in the Print method.
void Paint()
{
Graphics2D g2D=(Graphics2D)g;
Rectangle rect = newRectangle(10,10,20,20);
g2D.draw(rect);
}
public int print(Graphics g,PageFormat pageFormat,int pageIndex)throws PrinterException
{
if(pageIndex>0)
return NO_SUCH_PAGE;
Graphics2D g2D=(Graphics2D)g;

Rectangle rect = newRectangle(10,10,20,20);
g2D.draw(rect);

return PAGE_EXISTS;
}
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic