Swing Printing and LayoutManager

C

carl.manaster

Hi,

I evidently have a fundamental misunderstanding about printing,
components, and layout managers. Please help.

My applet's prepare-to-print code looks something like this:

setDoubleBuffered(false);
Container root = getContentPane();
root.setLocation(leftMargin, topMargin);
root.setSize(pageWidth, pageHeight);
....
root.invalidate();

and I expect that the new dimensions, or, failing that, at least the
invalidate() call, will cause the content pane's layout manager to get
a layoutContainer() call with the page dimensions. Not so. I put
printlns in layoutContainer, and it gets called just fine when the
window is resized, but never for printing (until it's done printing, at
which time it gets called with the screen coordinates).

How do I cause the pane to be laid out specially for printing? I
suppose I could call getLayoutManager().layoutContainer() - probably
that's what I'll try next - but what is the "right" way to do this?

Thanks.
 
C

carl.manaster

Update: getLayoutManager().layoutContainer() works fine. I'd still
appreciate an explanation of why it's needed - but I have a workaround,
in any event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top