Printer dialog!

Hi, I'd like to print a file/components to a printer without seeing the file/cmponents  on screen and without having the print dialog box poping out. I've been told that you could only bypass the print dialog box by playing in the peer win32(i am not sure about this expression).Where can I find it?
Is it possible to do this in jdl1.1.7.
I've been also told that jdk 1.2 offered the possibility of not having the dialog box pop up; but how do I implement this?
With regards
Who is Participating?
vladi21Connect With a Mentor Commented:
Printing Components: Frame Content to Image Object

Printing Swing Components in Java 1.2

How can I print the contents of a large JTable?

Java 1.1 
Using Design Patterns to Simplify Printing in Java 1.1 *
How do I print out a component in Java 1.1? 

Java 1.2
How can I speed up printing in my JDK 1.2 Swing application?

bugs in Java2 printing API 

  2. (Sect. 8) How do I print from a Java program?

     [*] Use the Toolkit.getPrintJob() method

     Component c = this.getParent();
     while (c!=null && !(c instanceof Frame))

     PrintJob pj = getToolkit().getPrintJob((Frame) c, "test", null);
     Graphics pg = pj.getGraphics();

     This feature was introduced with JDK 1.1. A common place to put this is
     in the code that handles a button press. Printing from an untrusted
     applet is subject to a check from the SecurityManager.

     The JDK 1.1 printing API is more a screen hardcopy facility than a full
     blown publishing and illustration hardcopy API. JDK 1.2 offers a more
     full-featured printing API.

     If you simply want to print text, then write it to a file and print the
     file. Or open a filename that corresponds to the printer. On Windows,
     that is "LPT1" and the code looks like:

     try {
         FileOutputStream fos = new FileOutputStream("LPT1");
         PrintStream ps = new PrintStream(fos);
                 ps.print("Your string goes here");
     } catch (Exception e) {
         System.out.println("Exception occurred: " + e);

     The final formfeed is needed by windows to start the printjob.

  3. (Sect. 8) What are the properties that can be used in a PrintJob? The
     properties are
        o awt.print.destination - can be "printer" or "file"
        o awt.print.printer - printer name
        o awt.print.fileName - name of the file to print
        o awt.print.numCopies - obvious
        o awt.print.options - options to pass to the print command
        o awt.print.orientation - can be "portrait" or "landscape"
        o awt.print.paperSize - can be "letter","legal","executive" or "a4"
     The defaults are destination=printer, orientation=portrait,
     paperSize=letter, and numCopies=1.

     You can search for info like this by joining the Java Developer
     Connection (it's free) at

     and doing a search for "PrintJob".



The JavaT Printing Project
a simple, easy to use, Pure JavaT, Open-Source printing package built on the current Java2 Platform printing API's.
Ability to print anything from plain text to complex documents.
PDF and PostScript output to files.
Print Preview with zoom in/zoom out ability.
Continuous updates through future Java PlatformT releases (i.e. Java3).

PriyanAuthor Commented:
Thank you very much  vladi21 thatreally helped me a lot
With best regards
PriyanAuthor Commented:
sorry for giving just 2 points for such a good answer,actually i didn't notice it.Actually for all my questions the last digit in ths points has been should have been 10/20 etc instead it is displaying 1/2.
with regards
All Courses

From novice to tech pro — start learning today.