| | |
Odd And Even
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
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
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
Java Syntax (Toggle Plain Text)
if ( pageIndex % 2 == 0 ) { // Even } else { // Odd }
New members chased away this month: 3
![]() |
Similar Threads
- Odd/Even Code (Java)
- Loop counting odd and even numbers (C++)
- Odd Page Cannot Be Displayed Problem (All browsers, not just IE) (Windows NT / 2000 / XP)
- Even / Odd code HELP!! (Java)
Other Threads in the Java Forum
- Previous Thread: Random Number Generator
- Next Thread: need help with while loop
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arc arguments array arrays automation binary bluetooth c++ chat class classes client code codesnippet component csv database doctype draw ebook eclipse error event exception fractal freeze game givemetehcodez graphics gui html ide image input integer intellij iphone j2me java java.xls javaprojects jmf jni jpanel julia linux list loop loops mac map method methods mobile netbeans newbie number online oracle page parameter plazmic print problem program programming project recursion reporting rotatetext scanner screen sell server set size sms socket sort sourcelabs sql string superclass swing system template test testautomation threads time title tree tutorial-sample windows working






