I have a JTextPane, and I want to make a page break, like what you see in MS Word. If the user typed over an A4 sized JTextPane, the prog will have to create another JTextPane to tell the user that its the end of the page and start from a new page.
There are a few problems to this issue:
1. Need to have a JScrollPane to the JFrame
2. Need to know when the user exceeds an A4 size TextPane. By the way, JTextPane's constructor doesnt include rows and cols. And we have to take to consideration the Font sized used also.
Any experts in Java GUI please help
Thanks in advance
I'm not entirely sure how the page break works in Word, so I can't help entirely there. However, your work should be with JScrollPane...not JTextArea.
From JScrollPane, there a method called getVerticalScrollBar. This returns a JScrollBar...from that, you can use getValue to see where it's at. You would probably want to add a DocumentListener to the JTextArea, and when the user types "\n" test the JScrollBar. and then do whatever you need to. Hope this helps a little...a little tricky, but I've gotten it to work before.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center