Article View: borland.public.jbuilder.java.swing
Article #10093Re: Printing Problem with Swing
From: Johan Forsberg
Date: Thu, 18 Nov 1999 00:00
Date: Thu, 18 Nov 1999 00:00
40 lines
2105 bytes
2105 bytes
Ravi <ravi@gseindia.com> wrote in message 381ED993.5480CF27@gseindia.com... > Hi all, > > I have a problem in printing using Swing components and Printer > Job. I have a panel with swing components - labels and check boxes. I > move values to these controls and call the PrinterJob class's print > method. > 1. The printer spooler file grows to 30MB. Is this reasonable? Is there > a way around it? Or am I missing something? > > 2. It takes 3 minutes to spool (because of the big size?). > > 3. The printout comes with a grey background. The panel color is set to > white. How to avoid this grey background? If your panel contains bitmaps or other items that cannot be printed using simple geometric shapes, PrinterJob will render it as a HUGE image (printer resolution) which is then painfully printed in tiny little strips. You may think 'So? I don't use any icons?'. Well, Swing double buffering is playing tricks on you... All JPanels are by default double buffered, which means that your panel first draws itself to an internal bitmap, which is then drawn to the PrinterGraphics, which in turn forces PrinterJob into bitmap mode. Hints on how to stay in vector mode: * NO icons. * NO fancy gradient fills. * call RepaintManager.setDoubleBufferingEnabled(false) before printing. The end result might still look a tad strange, since fonts and such are rendered at 4-8 times screen resolution. *But* it's lightning fast and doesn't use much memory either. HTH
Technical Details
Message-ID:
<810gej$rih13@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<381ED993.5480CF27@gseindia.com> <810dk7$rpq9@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,f33890880dac8f3 X-Google-Attributes: gid111d45,public From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se> Subject: Re: Printing Problem with Swing Date: 1999/11/18 Message-ID: <810gej$rih13@forums.borland.com> X-Deja-AN: 550057070 References: <381ED993.5480CF27@gseindia.com> <810dk7$rpq9@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing