Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Double-Sided

Reply
Thread Tools

Double-Sided

 
 
freesoft_2000
Guest
Posts: n/a
 
      02-01-2005
Hi everyone,

I am currently trying to print a swing component a JTable to
be exact but the thing is that i want my user to be able to print even,
odd or all the pages. The thing is i am using the swing print dialog and
not the windows native one.

When i write i use the printer job the java printing system will call the
page indexes as follows:

Code:
print(graphics, pageFormat, 0)
print(graphics, pageFormat, 1)
print(graphics, pageFormat, 2)
As you can see from above all the page numbers are called sequentially
until NO_SUCH_PAGE is returned.

Well what i am trying to say is that is possible to make the java printing
system only call odd page indexes
something like this

Code:
print(graphics, pageFormat, 0)
print(graphics, pageFormat, 2)
print(graphics, pageFormat, 4)
I know that it is also possible to print double side page by adding
attributes to the PrintRequestAttributeSet class by using the below line

Code:
add(Sides.DUPLEX)
This is not a very good option as it requires an expensive printer for
this and not many users have this type of expensive printer.

I hope i haven't confused you guys and maybe someone can explain or guide
me to a way to printing even and odd pages.

Please note that the JTable is three pages long

Thank You

Yours Sincerely

Richard West

 
Reply With Quote
 
 
 
 
Mario Winterer
Guest
Posts: n/a
 
      02-01-2005
Hi!

I think you cannot tell the printing system to just call odd or even pages.
But you can do that for yourself inside your print-method! Just do a conversion of the sequence 0,1,2,... into the sequence you want
(e.g. 0,2,4,... or 1,3,5...). The rest of your print method should then display the correct part of your table:

Code:
public int print(Graphics graphics, PageFormat format, int pageIndex) {
if (/*even pages?*/){
pageIndex = pageIndex * 2 + 1; // 1,3,5,...
} else if (/* odd pages? */) {
pageIndex = pageIndex * 2; // 0,2,4,...
}
....
}
"freesoft_2000" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) lkaboutprogramming.com...
> Hi everyone,
>
> I am currently trying to print a swing component a JTable to
> be exact but the thing is that i want my user to be able to print even,
> odd or all the pages. The thing is i am using the swing print dialog and
> not the windows native one.
>
> When i write i use the printer job the java printing system will call the
> page indexes as follows:
>
>
Code:
>
> print(graphics, pageFormat, 0)
> print(graphics, pageFormat, 1)
> print(graphics, pageFormat, 2)
>
>
>
> As you can see from above all the page numbers are called sequentially
> until NO_SUCH_PAGE is returned.
>
> Well what i am trying to say is that is possible to make the java printing
> system only call odd page indexes
> something like this
>
>
Code:
>
> print(graphics, pageFormat, 0)
> print(graphics, pageFormat, 2)
> print(graphics, pageFormat, 4)
>
>
>
> I know that it is also possible to print double side page by adding
> attributes to the PrintRequestAttributeSet class by using the below line
>
>
Code:
>
> add(Sides.DUPLEX)
>
>
>
> This is not a very good option as it requires an expensive printer for
> this and not many users have this type of expensive printer.
>
> I hope i haven't confused you guys and maybe someone can explain or guide
> me to a way to printing even and odd pages.
>
> Please note that the JTable is three pages long
>
> Thank You
>
> Yours Sincerely
>
> Richard West
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments