🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18911

Re: PRINTING WITH JAVA

#18911
From: Carlos Javier Castro Pe�a
Date: Sun, 05 Apr 1998 00:00
85 lines
2883 bytes
I posted a similar question and Darrier Forcier sent me the algorithm
that follows.
I didn't use it (The question was of a friend of mine:), but I hope it
helps.

/**
* Method:  PrintFrame(Frame pFrame, Component[] CompArray)
*
* @Author  Darren Forcier
*
* Purpose: Provide Applet-wide frame printing capability encapsulation
*
* Description
*
* This is an Applet-wide facility for printing frames.
*
*/

public void PrintFrame(Frame pFrame, Component[] CompArray ) {

    PrintJob prnJob;         // print job object
    Graphics pg;             // graphics context
    int i;

    // Hide components temporarily prior to printing
    for (i = 0; i < CompArray.length; i++) {
       CompArray[i].setVisible(false);
    }

    try {
       //PrivilegeManager.enablePrivilege("UniversalPrintJobAccess");
       // create printjob object and get graphics context
       prnJob = getToolkit().getPrintJob(pFrame,"Show
Confirmation",null);
       pg = prnJob.getGraphics();


       if (pg != null) {
          pFrame.paintAll(pg);    // print document
          pFrame.printAll(pg);
          pg.dispose();         // flush and send
       }
       prnJob.end();            // end print job
    }
   catch (Exception Err) {
      System.out.println("Something went wrong with printjob");
   }


    // Make components visible again
    for (i = 0; i < CompArray.length; i++) {
       CompArray[i].setVisible(true);
    }


}

Laurent LEFEVRE wrote:
> 
> Hi,
> 
> Is there a way to print with Java ?
> In a java application ?
> In an applet ?
> 
> There can I find examples  ?
> 
> Thanks
> 
> --
> Laurent LEFEVRE
> ====================================================================
> CO2W3         Parc d'activit� P�gase,            Tel : 02.96.05.82.40
>               1 rue Fulgence Bienven�e           Fax : 02.96.05.82.41
>               22300 LANNION - FRANCE             http://www.co2w3.fr
> --------------------------------------------------------------------
>  Logiciels Cooperatifs - Services Internet - Materiel Informatique

-- 
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Carlos Javier Castro Pe�a
email: jcaspen@iname.com
web:   http://www.latin-cancer.com/jcaspen
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Technical Details
Message-ID: <35282513.7E0BB924@iname.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3526173F.E1FB6905@co2w3.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,817cf4d4e43e330d
X-Google-Attributes: gidf74b3,public
From: "Carlos Javier Castro Pe�a" <jcaspen@iname.com>
Subject: Re: PRINTING WITH JAVA
Date: 1998/04/05
Message-ID: <35282513.7E0BB924@iname.com>
X-Deja-AN: 341205592
Content-Transfer-Encoding: 8bit
References: <3526173F.E1FB6905@co2w3.fr>
To: Laurent LEFEVRE <laurent.lefevre@co2w3.fr>
Content-Type: text/plain; charset=iso-8859-1
Organization: Univerity of Kansas
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language