-
Page break
Page break
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks