Forum Stats

  • 3,874,989 Users
  • 2,266,791 Discussions
  • 7,912,045 Comments

Discussions

Printing properties problem

860088
860088 Member Posts: 10
edited Dec 11, 2011 4:08PM in Java Desktop Applications
Hi everybody... This might be lame, but i'm stuck with printing. Actually I get the string printed but I wanted to disable the printer dialog box and just print with default settings to the default printer.

below is the code that i use for printing:
try {
            boolean complete = tbPrint.print(null, null, true, null, null, false);
            if (complete) {
                tbPrint.setText("");

            } else {

            }
        } catch (PrinterException pe) {

        }
I was searching Google for an example but every example is very very long because includes printing graphics etc.

Can someone guide me through this problem?

Thanks in advance!

Best Regards,
Dean

Edited by: dkocevski on Dec 11, 2011 8:35 AM

Edited by: dkocevski on Dec 11, 2011 8:35 AM
Tagged:

Answers

  • 860088
    860088 Member Posts: 10
    Problem solved! :)

    The code:
    try {
                
                String s = tbPrint.getText();
                tbPrint.print(null, null, false, null, null, false);
                
            } catch (java.awt.print.PrinterException ex) {
                
                ex.printStackTrace();
                
            }
    I set the third attribute of the print() function to 'false' and it doesn't show the printing dialog, just passes the job to the default printer.

    I just need to check the other attributes to see what else can i pre-configure... page size, margins, etc.

    Best Regards,
    Dean
This discussion has been closed.