0

I've added multiple components to my LWUIT Form one by one,but the problem is i am not able to display those added components one by one as like i appended in my code,i am able to display date and my image on a single row(side by side)some times title and date on a single row,I am getting the details from Rss File. How to display those components like i added in my code one by one, but not 2 components in a single row?

thanks....

Here my code:

 Label pubDate = new Label(detailNews.getPubDate().substring(0, 16));
        Label title=new Label();
        title.setText(detailNews.getTitle());
        title.startTicker();
        pubDate.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));
            Image geImage = detailNews.geImage(); 
        Label icon=new Label(geImage);
                form2.addComponent(title);
                form2.addComponent(pubDate);
        textarea.setText(detailNews.getDescription());
        textarea.requestFocus();
      form2.addComponent(icon);
       form2.addComponent(textarea);
        form2.show();
String
  • 3,660
  • 10
  • 43
  • 66

1 Answers1

2

My idea is:

You can create a Container with a BoxLayoutY, and add this TextArea and the icon to the Container. Next, add this Container to the Form. Something like:

       Label pubDate = new Label(detailNews.getPubDate().substring(0, 16));
        Label title=new Label();
        title.setText(detailNews.getTitle());
        title.startTicker();
        pubDate.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));
            Image geImage = detailNews.geImage(); 
        Label icon=new Label(geImage);

        Container container = new Container(new BoxLayout(BoxLAyout.Y_AXIS));
        container.addComponent(title);
        container.addComponent(pubDate);
        container.addComponent(icon);
        container.addComponent(textarea);
        form2.addComponent(container);

        textarea.setText(detailNews.getDescription());
        textarea.requestFocus();
        form2.show();
Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • I've modified my code and tested,it's not working...,if i use and execute my code and your's code,For few items i am able to display correctly(i.e 1)Title,2)PublishDate,3)Image,4)Description line by line) But for few items i am able to display(i.e 1)title and image in a single row,2)PublishDate,3)Description? – String Oct 11 '12 at 04:53
  • Ok sorry, I forget something in the code. I´m going to edit, check it please – Mun0n Oct 11 '12 at 11:24
  • if i add Everything in side the container,i am facing the Exception,it was java.lang.IllegalArgumentException: Component is already contained in Container: Container[x=0 y=0 widt etc.... – String Oct 11 '12 at 11:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/17909/discussion-between-pavan-kumar-ragi-and-jmunoz) – String Oct 12 '12 at 06:00
  • yes,The Exception was pointing at this line form2.addComponent(container); Exception,it was java.lang.IllegalArgumentException: Component is already contained in Container: Container – String Oct 12 '12 at 06:02
  • So, my last idea, if this Cointainer is not working. You can put the Box Layout Y to the form and add the components – Mun0n Oct 12 '12 at 12:52