Hi everyone,

I am doing a simple program with some text in the jtextpane and the text inside the jtextpane span to about three standard A4 papers. What i want to do is to only be able print even and odd pages. I am using currently the java printable interface in which i must overide the print method which has the following declaration

public int print(Graphics pg, PageFormat pageFormat, int pageIndex)
{
}

I Know that printing even or odd pages does not involve the graphics or the pageformat objects.

The pageindex object is the one i am concerned about.

The thing is i do not know how to test as to whether the pageindex is an even or odd number (including 0 which is an odd number)

Can anyone show me any codings or explain to me in detail how to test for even or odd numbers.

Thank You

Yours Sincerely

Richard West

if ( pageIndex % 2 == 0 ) {
  // Even
}
else {
  // Odd
}