>Thanks for answering but i dont understand a little
>you edit pritn method but you dont call becuase you use only print();
The class should implement the Printable interface. You don't need to call
the print(Graphics g, PageFormat pf, int pi) directly. When you call
print(), that in turn calls print(g, pf, pi).
Ex:
public class MyPrintClass extends JFrame implements Printable
{
String imageFilename;
public MYPrintClass(String imageFilename)
{
super("Printing Image");
this.imageFilename = imageFilename;
}
public printImage()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
PageFormat pf =
printJob.pageDialog(printJob.defaultPage());
if (printJob.printDialog())
{
try
{
printJob.print();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException
{
Image img =
Toolkit.getDefaultToolkit().getImage(imageFilename);
g.drawImage(img, 72, 72, 468, 648, this);
return Printable.PAGE_EXISTS;
}
}
>besides.. what is defaultToolkit? my java dont understand that i can find it
Sorry, my fault, it should be
Toolkit.getDefaultToolkit().getImage(imageFilename);
Check the "Printing" section of 2DGraphics in Java online tutorial. It also
has an example for printing multiple pages.
Gopi
>atte
>
>Christian Hamann Linares
>Area de Desarrollo de Aplicaciones
>FICS-DATA USMP
>e-mail: [EMAIL PROTECTED]
>----- Original Message -----
>From: Gopi Mandava <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Monday, January 15, 2001 9:56 AM
>Subject: Re: Print image and show it
>
>
> > Inserting images depends on what DB you are using.
> >
> > For printing, you can use java print classes, java.awt.print.*. Try the
> > following code:
> >
> > public void printMyImage()
> > {
> > PrinterJob printJob = PrinterJob.getPrinterJob();
> > printJob.setPrintable(this);
> > if (printJob.printDialog())
> > {
> > try
> > {
> > printJob.print();
> > }
> > catch (Exception ex)
> > {
> > ex.printStackTrace();
> > }
> > }
> > }
> >
> > public int print(Graphics g, PageFormat pf, int pi) throws
>PrinterException
> > {
> > Image img = Toolkit.defaultToolkit.getImage("test.jpg");
> >
> > if (pi >= 1) {
> > return Printable.NO_SUCH_PAGE;
> > }
> >
> > Rectangle rect = g.getClipBounds();
> > g.drawImage(img,
> > (int)rect.getX(), (int) rect.getY(),
> > (int) rect.getWidth(),
> > (int) rect.getHeight(),
> > this);
> >
> > return Printable.PAGE_EXISTS;
> > }
> >
> > The class where you do the printing from should implement the Printable
> > interface.
> >
> > Gopi
> > > > Hi all
> > > > i have a problem with images.. how can i to do to insert in my
>Database
> > >with
> > > > Blob class and how can i do to get this image.... my image is jpg..
> > >another
> > > > thing how can i to print it
> > > > thanks
> > > >
> > > > Christian Hamann Linares
> > > > Area de Desarrollo de Aplicaciones
> > > > FICS-DATA USMP
> > > > e-mail: [EMAIL PROTECTED]
> > > > ----- Original Message -----
> > > > From: <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Wednesday, December 27, 2000 8:37 PM
> > > > Subject: Returned mail - agrino.org
> > > >
> > >
> >
> >===========================================================================
> > >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > >JSP-INTEREST".
> > >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
> > >Some relevant FAQs on JSP/Servlets can be found at:
> > >
> > > http://java.sun.com/products/jsp/faq.html
> > > http://www.esperanto.org.nz/jsp/jspfaq.html
> > > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >
> > -----------
> > Gopi Mandava (703) 267-1735 x307
> > CoManage Inc.
> >
> > "I don't think God put me on this planet to judge others. I think he put
>me
> > on this planet to gather specimens and take them back to my home planet."
> >
> >
>===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
-----------
Gopi Mandava (703) 267-1735 x307
CoManage Inc.
"I don't think God put me on this planet to judge others. I think he put me
on this planet to gather specimens and take them back to my home planet."
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets