🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Printing: I get Print Dialog, but nothing prints!

#19132
From: Marc Jourdenais
Date: Mon, 09 Mar 1998 00:00
83 lines
3986 bytes
Alex,

Sun has apparently screwed up the printing in every release of the JDK on Win32
so far.  The bugs vary from release to release.  They include page sizing,
component printing (your problem), and crashing.  Microsoft hasn't mastered
this functionality either.

In my experience, JDK1.1.5 is going to print garbage when you use printAll() or
printComponents().  JDK1.1.4 or the current Microsoft VM will print a
reasonable facsimile of your frame. Apparently 1.1.4 was the only release where
Sun came close.  Yes, they broke it again in 1.1.5.  The MS VM tends to leave
out the actual text inside edit boxes.

Knowing that you are exclusively using Win95 and NT doesn't help much, since
this platform  is the root of the problem. If you are interested in the bug
reports, start with bug #4084038 on the JDC bug parade.

The best advice I can give you is to try the 1.1.4 and MS VMs and see if their
printing is good enough for your needs.  Or wait for Sun to fix it.

If you want to be platform specific, there may be a way to do a native call out
to the OS (using JNI or JDirect), asking it to dump the window or the screen.
This is outside my area of knowledge, though, and a nasty business.

Good Luck (I'm afraid you'll need it),
Marc

Alex Humphreys wrote:

> Bugs?  What bugs?
>
> Is there a way to get it to work if I know the operating system (we're
> exclusively using windows 95 and NT)?  Is there another way to print the
> screen as a graphic (I'd rather not convert everything to a String)?
>
> Help!  It worked fine in JBuilder but when I ran it as a stand-along I
> printed up some sort of random jarble of all that I wanted to print.
>
> Thanks.
>
> Marc Jourdenais wrote:
>
> > Alex,
> >
> > This code is asking the AWT to print all the components in your Frame.
> > What should be printed depends on the components you have added to your
> > Frame before this is called.  The components are in turn asked to draw
> > themselves.  Since you are doing this before the Frame is shown, you may
> > have some odd behavior.
> >
> > You should be aware that printAll() is in some way broken in most of the
> > VMs out there.  JDK1.1.5 has bugs logged against it.  So what *should*
> > print is not necessarily what *will* print, even if you code it properly.
> > The peers tend to misbehave in this case.
> >
> > If you just want to print a string, you should call
> > myGraphics.drawString(...), not printAll(...).
> >
> > - Marc
> >
> > Alex Humphreys wrote:
> >
> > > I'm trying to print a string, but for some reason I get Windows' Print
> > > Dialog, but then Nothing Prints.  I've tried to follow the instructions
> > > I've found in this newsgroup, and nothing seems to help.
> > >
> > > I have the following in my jbinit of a Frame I just created.  the print
> > > dialog comes after the first line, so the Graphics calls don't seem to
> > > do anything.
> > >
> > >     PrintJob myJob =
> > > Toolkit.getDefaultToolkit().getPrintJob(this,"AlexH",new Properties());
> > >     Graphics myGraphics = myJob.getGraphics();
> > >     this.printAll(myGraphics);
> > >     myGraphics.dispose();
> > >     myJob.end();
> > >
> > > (incidentally, what should be printed if I do this?  an image of the
> > > Frame?  A string that I can specify?)
> > >
> > > Thanks.
> > > --Alex
Technical Details
Message-ID: <35045CE1.47171F91@pcn.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34FDB70E.5A5784F6@sema4.com> <34FDCFC6.2CF368E1@pcn.com> <35045370.600D19B5@sema4.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,56b3af2cddf188a7
X-Google-Attributes: gidf74b3,public
From: Marc Jourdenais <mjourden@pcn.com>
Subject: Re: Printing:  I get Print Dialog, but nothing prints!
Date: 1998/03/09
Message-ID: <35045CE1.47171F91@pcn.com>
X-Deja-AN: 332396226
Content-Transfer-Encoding: 7bit
References: <34FDB70E.5A5784F6@sema4.com> <34FDCFC6.2CF368E1@pcn.com> <35045370.600D19B5@sema4.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language