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. 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. oziris
    Replies:
    2
    Views:
    2,952
    Thomas Fritsch
    Dec 9, 2005
  2. keto
    Replies:
    0
    Views:
    1,049
  3. Replies:
    2
    Views:
    5,364
    ambri
    Jun 6, 2011
  4. MATTXtwo
    Replies:
    0
    Views:
    527
    MATTXtwo
    Jan 12, 2010
  5. Replies:
    3
    Views:
    418
Loading...

Share This Page