943,491 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 9195
  • Java RSS
Oct 27th, 2004
1

Odd And Even

Expand Post »
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
Similar Threads
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004
Oct 27th, 2004
0

Re: Odd And Even

Java Syntax (Toggle Plain Text)
  1. if ( pageIndex % 2 == 0 ) {
  2. // Even
  3. }
  4. else {
  5. // Odd
  6. }
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Random Number Generator
Next Thread in Java Forum Timeline: need help with while loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC