Search code examples
java-melwuit

LWUIT Form with multiple Components


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();

Solution

  • 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();