Frage

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.

War es hilfreich?

Lösung

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.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top