Article View: borland.public.jbuilder.java.language
Article #19655Re: Problems printing?
From: Andrew Bennett
Date: Fri, 09 Jan 1998 00:00
Date: Fri, 09 Jan 1998 00:00
44 lines
1857 bytes
1857 bytes
Todd Prisbe wrote:
> I'm having trouble getting printed output from a java application. I get
> the Windows print dialog box, but then all I get is a blank page. My sample
> printing app source code is below. What am I doing wrong?
> void buttonControl1_actionPerformed(ActionEvent e) {
> String name = "Test Print Job";
> Properties prop = new Properties();
> PrintJob pj = tk.getPrintJob(PrintTestApp.this, name, prop);
> if (pj == null) ta.setText("A null PrintJob was returned.");
> String output = "\nTest of printing";
> ta.setText(output);
> pj.getGraphics().dispose();
> pj.end();
> }
You have to get a PrintJob object from the Toolkit, then call
getGraphics on the PrintJob to obtain a Graphic object.
Something like:
PrintJob myJob = Toolkit.getDefaultToolkit().getPrintJob(this,"whatever",new
Properties());
Graphics myGraphics = myJob.getGraphics();
this.printAll(theGraphics);
myGraphics.dispose();
myJob.end();
Hope that helps
Andrew
--
Andrew Bennett -> abennett@borland.com
JBuilder info -> http://www.borland.com/jbuilder/
JBuilder newsgroups info -> http://www.borland.com/newsgroups/
**** Please don't post a reply AND send email. Do one. I'll see it. ****
Technical Details
Message-ID:
<34B6A806.5BA1AA5@borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<693eaj$6i81@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,d0dc6de8af7c3ea5 X-Google-Attributes: gidf74b3,public From: Andrew Bennett <abennett@borland.com> Subject: Re: Problems printing? Date: 1998/01/09 Message-ID: <34B6A806.5BA1AA5@borland.com> X-Deja-AN: 314458483 Content-Transfer-Encoding: 7bit References: <693eaj$6i81@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: None Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language