Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7020037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:15:56+00:00 2026-05-27T23:15:56+00:00

Possible Duplicate: How to set AUTO-SCROLLING of JTextArea in Java GUI? I’m creating an

  • 0

Possible Duplicate:
How to set AUTO-SCROLLING of JTextArea in Java GUI?

I’m creating an application in which the user types the text in a TextField from which the text is appended to a TextArea when an actionPerformed.
The TextArea is added on a JScrollPane. When the number of line out of declared column the user can scroll to see the text. But he need to scroll every-time when he enters some text to TextArea via TextField because the last line appended to the TextArea does not automatically scroll to last line.
Can anybody help me out there how to either automatically or when the actionPerformed, the TextArea will be scrolled to last?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:15:56+00:00Added an answer on May 27, 2026 at 11:15 pm

    Try this:

    jTextArea.selectAll();
    int last = jTextArea.getSelectionEnd();
    jTextArea.select(last, last);
    

    Where jTextArea is a reference to your TextArea.

    However, the previous example might be extremely slow if there is a lot of text, so I’ve provided another way to do this:

    jTextArea.setCaretPosition(jTextArea.getDocument().getLength());
    

    EDIT: After surfing around on the Internet for alternative solutions and reading this answer to a similar question, I realized that @kleopatra’s solution is the more effective. However, it is entirely your prerogative to accept whatever answer you see fit (I see you’ve accepted mine).

    @kleopatra I upvoted you to compensate. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: C# How can I set the color of text in a richtextbox?
Possible Duplicate: How To Set Text In An EditText how can we assign value
Possible Duplicate: How can I set the umask from within java? How do you
Possible Duplicate: How do I set environment variables from Java? I'm trying to set
Possible Duplicate: Adding an identity to an existing column how to set auto increment
Possible Duplicate: How to set android show vertical orientation? I'm trying to disable auto
Possible Duplicate: CKEditor - Set cursor position to end of text I have a
Possible Duplicate: Retrieving the last record in each group I have two tables set
Possible Duplicate: C# generic constraint for only integers Greets! I'm attempting to set up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.