Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Printing using Java

Printing using Java

From: Tarek Shaar <tareks_at_syslogic.com>
Date: Tue, 09 Nov 1999 05:18:23 GMT
Message-ID: <3827aa9f.25004845@news.demon.co.uk>


Hello every body

I have this small problem, I am trying to print out text from a Java application . The idea is supported by AWT and it is to use the paint method to dispaly text and instead of writting to the screen write to the printout. What I am trying to do is to print out a report whitch has different text lables. At the moment I am trying to set up the lables for the report, which I have already done but when I print out the report, only one lable shows on the print out without the rest of them.
The code to set up all the printting info is as follows

private void print(ActionEvent e)

   {

       PrintJob pjob = getToolkit().getPrintJob(this,"Print",null);

       if (pjob != null)
       {
        Graphics pg = pjob.getGraphics();
       
        if (pg != null)
        {
            paint(pg);
            pg.dispose(); //flush page
         }
         pjob.end();
       }

   }

and the code for the paint method to dispaly the text is as follows:

public void paint(Graphics g)
  {     

    g.setFont(new Font("Italic",Font.BOLD,18));    

     //draw the title of the page
     String title "Problem Report";
     g.drawString(title,150,30);
   
    //draw the equipment subtitle
     g.setFont(new Font("Italic",Font.ITALIC,12));
     g.drawString("Equipment",35,70);
    

  }

When I run the program both lables appear on the screen but when I print out the reprot only the first lable appears

Does any one know why
if yes then please email me back as soon as possible

Thanks
Tarek Received on Mon Nov 08 1999 - 23:18:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US