Results 1 to 5 of 5
  1. #1
    corbokhan is offline Member
    Join Date
    Oct 2010
    Posts
    16
    Rep Power
    0

    Default Default JScrollPane At The Top

    I have a problem regarding a JScrollPane on my JTextArea.

    When I paste text into the TextArea, the ScrollBar automatically scrolls to the bottom of the textbox. I want the ScrollBar to stay at the top of the textbox when I paste text into the box. How can I set the ScrollBar to stay at the top of the textarea when I paste text into it?

  2. #2
    joshdgreen's Avatar
    joshdgreen is offline Senior Member
    Join Date
    Oct 2010
    Location
    Colorado Springs, CO
    Posts
    212
    Rep Power
    4

    Default

    You could try setting the caret position to the top, read this to get an idea: JTextComponent (Java Platform SE 6)
    Sincerely, Joshua Green
    Please REP if I help :)

  3. #3
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    I am doing this blind but there is a caret function if i am not mistaken
    setting
    bodyText.setCaretPosition(0);
    after pasting assuming bodyText is a JTextArea

    again I am coding blind here so there might be better solutions

    edit: joshdgreen post says it
    Last edited by al_Marshy_1981; 10-28-2010 at 01:22 AM. Reason: too slow..very slow in fact

  4. #4
    corbokhan is offline Member
    Join Date
    Oct 2010
    Posts
    16
    Rep Power
    0

    Default

    Great! thanks a lot for the help.

    Really appreciate your feedback Marshy!

  5. #5
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    No worries I still have your code from the previous question so was able to show you where...do read up on what joshdgreen posted though

Similar Threads

  1. Changing JScrollPane default viewing position
    By peterhabe in forum AWT / Swing
    Replies: 7
    Last Post: 10-07-2010, 08:44 PM
  2. Copy Default table model to another default table model?
    By greatmajestics in forum AWT / Swing
    Replies: 2
    Last Post: 04-28-2010, 04:08 PM
  3. Replies: 1
    Last Post: 03-10-2009, 01:12 PM
  4. jscrollpane
    By kaemonsaionji in forum New To Java
    Replies: 3
    Last Post: 02-25-2009, 08:39 AM
  5. help with JScrollPane
    By tommy in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 07:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •