Hi everyone,

I have a jtextpane with some text which spans to about 10 pages and what i want to able to insert page numbers into the center bottom of the page. I am using the DefaultStyledDocument class as the default document type for my jtextpane.

I hope someone can explain to me or show me some codings that can help me to insert the page numbers into the jtextpane

Thank You

Yours Sincerely

Richard West

Recommended Answers

All 3 Replies

You don't want the page numbers inserted into the text editor.
What will happen if you add or remove text? The numbers will now no longer be properly positioned, instead showing in the middle of the pages.

Instead you'd better customise your printing routine (I guess you want to print things?) to insert page numbers every X lines and a pagebreak directly after that.

hi everyone,
Yes you are right but how will you go about doing this

Richard West

Hi everyone,

I managed to do it thanks to you pointing me to the right direction
jwenting

Any way here is what i added in

g.drawString(("Page " + (pageIndex + 1)), 225, 645);

Thank You

Richard West

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.