Swing Printing and LayoutManager

Discussion in 'Java' started by carl.manaster@gmail.com, May 22, 2006.

  1. Guest

    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.
     
    , May 22, 2006
    #1
    1. Advertising

  2. Guest

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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big Daddy

    Java 1.2 Swing vs. Java 1.5 Swing

    Big Daddy, Apr 15, 2005, in forum: Java
    Replies:
    2
    Views:
    523
    Pete Barrett
    Apr 16, 2005
  2. mkrause
    Replies:
    0
    Views:
    700
    mkrause
    May 6, 2005
  3. John F.
    Replies:
    8
    Views:
    952
    Andrey Kuznetsov
    Dec 7, 2005
  4. lizard
    Replies:
    0
    Views:
    1,801
    lizard
    Jan 30, 2006
  5. Sam Takoy

    Custom LayoutManager troubles

    Sam Takoy, Apr 5, 2010, in forum: Java
    Replies:
    4
    Views:
    320
    markspace
    Apr 5, 2010
Loading...

Share This Page