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 7019273
In Process

The Archive Base Latest Questions

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

Using LWUIT, I have a Form with two components: a read-only TextArea and a

  • 0

Using LWUIT, I have a Form with two components: a read-only TextArea and a Button:

TextArea text = new TextArea("blah blah blah blah blah blah blah blah blah ...");
text.setEditable(false);
form.addComponent(text);

Button button = new Button("Press Me !");
button.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent evt) {
          // DESIRED CODE IS HERE ...
     }
});
form.addComponent(button);

The TextArea has a Scrollbar because it contains a long String, when the user moves DOWN the TextArea‘s Scrollbar moves down until it reaches the end of the String, then the Button get focused leaving the TextArea‘s Scrollbar at the end of the TextArea.

I want that, when the Button is clicked, the scrollbar returns back to its original state in the Top of the TextArea instead of being in the Bottom of the TextArea. How could I do this ?

  • 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:09:43+00:00Added an answer on May 27, 2026 at 11:09 pm

    Here’s the solution for those who are interested.
    by using a custom TextArea

    public class CustomTextArea extends TextArea {
        public TextAreaScrollControlled(String text) {
            super(text);
        }
    
        public void resetScrollBackToTop() {
            setScrollY(0);
        }
    }
    

    Then the code is the following (instead of the one posted in the question):

    CustomTextArea text = new CustomTextArea("blah blah blah blah blah blah ...");
    text.setEditable(false);
    addComponent(text);
    
    Button button = new Button("Press Me !");
    button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
              text.resetScrollBackToTop(); // SOLUTION
         }
    });
    form.addComponent(button);
    

    PS. “text” should be final or a member of the class 😉

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

Sidebar

Related Questions

Using LWUIT, I have a Form (form1) which contains a Button (see the silver
I have created button without any border using LWUIT resource editor. I am able
I have started using LWUIT which sounds interesting , i have made a form
I am using LWUIT package for my j2me application.In my application, i have extends
I am using LWUIT in j2me. There is only one .java file containing midlet
i tried to show the calendar on button click using form but i'm unable
Using MVC2 I have an AJAX form which is posting to a bound model.
I have a standard com.sun.lwuit.list . I can get the selected item using methods
i'm using lwuit videocomponent to play video. import com.sun.lwuit.Button; import com.sun.lwuit.Display; import com.sun.lwuit.Font; import
I have Created one Program Using Lwuit,Midlet. In that program I am showing Dialog

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.