1

I have a TextArea in LWUIT that I am having an issue manipulating. I have the following two issues:

  1. Even though I call setIsScrollVisible(true), I do not seem to have a scrollbar and cannot scroll when the output goes below the visible area of the container.

  2. How do I tell the TextArea to automatically scroll to the bottom programmatically?

My code for initializing the TextArea looks like this:

myTextArea = new TextArea(20, Display.getInstance().getDisplayWidth());
myTextArea.setEditable(false);
myTextArea.setEnabled(true);
myTextArea.setIsScrollVisible(true);
myTextArea.setGrowByContent(false);
System.out.println(myTextArea.isScrollableY());

isScrollableY() returns true. Any ideas? Is there something I am missing? There doesn't seem to be anything visible in the API that lets me explicitly enable or disable scrolling. Thanks in advance for any assistance on this.

bharath
  • 14,283
  • 16
  • 57
  • 95
codewario
  • 19,553
  • 20
  • 90
  • 159
  • I have tested your code its working fine for me. And why you pass `Display.getInstance().getDisplayWidth()`? – bharath Oct 05 '11 at 11:21
  • I want the form to be as wide as the screen. If this code is working fine with a standard JVM, then perhaps there is an issue with the proprietary implementation I am working with? – codewario Oct 06 '11 at 14:25

2 Answers2

3

The width of the text area is in columns NOT pixels as you have in your code.

Setting the scroll to visible won't cause it to appear since LWUIT scrollbars are always "as needed" which means a scrollbar will only appear when necessary, setting this value to false would just hide the scrollbar regardless of necessity.

To have the text area grab the entire width just place it within a box layout Y container/form and the layout manager will stretch it on the X axis.

You can use scrollRectToVisible() to scroll the text area to the bottom or alternatively you can derive text area and use setScrollY(int) with the appropriate value (see the source code of text area for how this is used to scroll the text area.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I know it is not by pixels, however, I thought I tried using scrollRectToVisible() and it didn't work. I will give this another go and report back, but I am currently working on other areas of this project so it may be a while before I am able to test this. – codewario Oct 10 '11 at 15:42
  • It turns out there was an issue from our client's initial deliverable, the latest update allowed the methods pertaining to scrolling to work properly. – codewario Oct 17 '11 at 15:55
0

Try a simple textArea.setFocusable(false). This worked for me.

Siklab.ph
  • 991
  • 11
  • 17