Print and print overview and current page

Discussion in 'Java' started by Bernard Segonnes, Nov 4, 2004.

  1. Hi,

    I will have several pages to print.
    I need to have an overview of 1 page at the time (in a JPanel), and
    the possibility to use the same JPanel to display another page.
    This JPanel will be able to print all pages.

    1)Is it possible to use the same method (drawPage() ) to print 1 page
    (called from print() and from paint() ) ?

    2) How can I know the page number I have to display in paint() ?

    3) How do I know how to create a new page ?

    4) How can I count the number of pages before printing (in the oveview
    on the screen) ?


    book = new Book();
    printAndOverview = new PrintAndOverview();
    book.append(printAndOverview,myPageFormat);
    job.setPageable(book);
    ....


    private class PrintAndOverview extends JPanel implements Printable {

    public PrintAndOverview() {
    super();
    setVisible(true);
    }


    public int print(Graphics g, PageFormat format, int pageIndex) {
    super.print( g);
    drawPage((Graphics2D) g);
    return Printable.PAGE_EXISTS;
    }

    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    drawPage((Graphics2D) g);
    }

    private void drawPage(Graphics2D g2){
    g2.drawString("page number XXX",10,10);
    ..... a lot of stuff
    }// drawPage()

    }



    Thanks for your help
     
    Bernard Segonnes, Nov 4, 2004
    #1
    1. Advertisements

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. laurence chang

    How to add a print current page function

    laurence chang, Sep 29, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,815
    =?Utf-8?B?QW5kcmUgUmFuaWVyaQ==?=
    Sep 29, 2005
  2. oziris
    Replies:
    2
    Views:
    3,428
    Thomas Fritsch
    Dec 9, 2005
  3. keto
    Replies:
    0
    Views:
    1,361
  4. Replies:
    2
    Views:
    6,318
    ambri
    Jun 6, 2011
  5. MATTXtwo
    Replies:
    0
    Views:
    648
    MATTXtwo
    Jan 12, 2010
  6. Veloso
    Replies:
    10
    Views:
    262
    Rick DeNatale
    Apr 4, 2008
  7. Jack
    Replies:
    3
    Views:
    882
    Tad J McClellan
    Dec 22, 2008
  8. Replies:
    3
    Views:
    596
Loading...