DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Page break

  1. #1
    Join Date
    Nov 2002

    Lightbulb 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

  2. #2
    Join Date
    Nov 2002
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.