0

Here is my code. I want the 20th Label be visable, anyone knows how to accomplish it.

another post Auto Scrolling in LWUIT Container says componentOfLastContainer.requestFocus(); centerBigContainer.repaint(); will work,but it seems not work for me. I need Your help ,thanks

public class TestView extends Form{
private TextArea inputText;
private Container chatScreen = new Container(new BoxLayout(BoxLayout.Y_AXIS));

public TestView () {
    super("test", null);
    setupUI();
        }

void setupUI() {
    setLayout(new BorderLayout());
    setScrollable(false);
    chatScreen.setScrollableY(true);
    addComponent(BorderLayout.CENTER, chatScreen);
    inputText = new TextArea(2, this);
    inputText.setGrowByContent(true);
    inputText.setMaxSize(1000);
    Container sendContainer = new Container(new BorderLayout());
    sendContainer.addComponent(BorderLayout.CENTER, inputText);
    addComponent(BorderLayout.SOUTH, sendContainer);


    for (int i = 0; i < 20; i++) {
        Label l = new Label("sdjfksjfksjd" + i);
        c = new Container();
        c.addComponent(l );
        chatScreen.addComponent(c);
    }

  c.requestFocus();

  chatScreen.repaint();


    Display.getInstance().callSerially(new Runnable(){

            public void run() {
                  c.requestFocus();

                 chatScreen.repaint();
            }
        });


}
Community
  • 1
  • 1
phx
  • 3
  • 2

1 Answers1

0

I'm guessing that if request focus isn't working for you its related to the text area you have there. I can't really help much with the Nokia fork but this should work on Codename One.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • thanks very much for your reply. I want to implment a chat page like this layout, Messages above and input Textarea below. When new msg comes,it added to the end of chatScreen,and chatScreen should scroll to the end item. Do you know other ways to achieve my pupurse. – phx Jan 11 '13 at 09:07
  • Another question, Textarea can't grow by content,when construct by 1 row. I want construct 1 row TextArea, then with the user input increase the TextArea also grown, Do you know how to ? thanks again – phx Jan 11 '13 at 09:14
  • These are both different questions you should generally accept the answer and create a new one. I suggest you look at the Chat Demo in the LWUIT repository at http://lwuit.java.net/ where it shows an iPhone like bubble chat. Text area can grow it just complicates some things in terms of layout since the layout needs to reflow and layout reflow is difficult to achieve in a performant way. – Shai Almog Jan 11 '13 at 13:04
  • Ok,I accept it. But my problem haven't solved.Can you send a Email to me,then I can show you my demo.And Maybe you will find how to solve it.Thanks a lot. My Email 254035543@qq.com. I need your help,I have implement bublle style meesage. With your help I will implement a betutiful chat application – phx Jan 13 '13 at 02:41
  • I have looked your pimp chat demo,which is helpful for me to implemnt bubble style message. But I can't find the answers to fix my two problem yet. 1,how does the chatScreen auto scroll? 2,the textarea grown from 1 row. and the first is more important,because it will give user normal chat experience – phx Jan 13 '13 at 03:15
  • By the way,pimp chat demo display not perfect,because your init row of TextArea is 1.And is this the version for s40 not solved this problem. Now we focus on first issue.How make it auto scroll. You can try lwuit for s40,using pimp chat demo. – phx Jan 13 '13 at 06:23
  • I can't really help you there, like I said we are working on Codename One and don't invest anymore effort in LWUIT. You can checkout the Facebook chat demo in Codename One which implements a bubble chat and is open source. Unlike the old demo it also animates the chat operations into place. – Shai Almog Jan 13 '13 at 11:42
  • I post this issue on nokia developer Community, I will tell when I get progress.By the way,codename one is wonderful, hope someday it will be used on s40. – phx Jan 14 '13 at 10:04
  • there is another issue need your help,thanks http://stackoverflow.com/questions/14318448/lwuit-lost-keyreleased-event – phx Jan 14 '13 at 12:32