Print and print overview and current page

  • Thread starter Bernard Segonnes
  • Start date
B

Bernard Segonnes

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top