×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

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

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Hyderabad,AP,India.
    Posts
    62

    Re: LWUIT Form with multiple Components

    Hi pavanragi,

    U can add more than one component in a single row as:
    1)Take a new LWUIT container with BoxLayout as x-axis and add the components to the container that u want to be in a single row.
    2) Add the container to the LWUIT Form
    Regards,
    Harsha

  3. #3
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Re: LWUIT Form with multiple Components

    Hi harsha

    I've modified my code like you said,Here is the Code:

    Container container = new Container(new BoxLayout(BoxLayout.X_AXIS));
    container.addComponent(pubDate);
    container.addComponent(icon);
    textarea.setText(detailNews.getDescription());
    container.addComponent(textarea);
    form2.addComponent(container);
    form2.show();
    But ,i am getting the Exception:
    java.lang.IllegalArgumentException: Component is already contained in Container: Container[x=0 y=0 width=238 height=85, layout = BoxLayout, scrollableX = false, scrollableY = false, components = [Label, Label, TextArea]]
    - com.sun.lwuit.Container.insertComponentAt(Container.java:370)



    Quote Originally Posted by harsha921 View Post
    Hi pavanragi,

    U can add more than one component in a single row as:
    1)Take a new LWUIT container with BoxLayout as x-axis and add the components to the container that u want to be in a single row.
    2) Add the container to the LWUIT Form

  4. #4
    Registered User
    Join Date
    May 2012
    Location
    Hyderabad,AP,India.
    Posts
    62

    Re: LWUIT Form with multiple Components

    Hi pavanragi,

    Only add the components which u want them to be in a row. Check your code once thouroughly where you are adding the components.
    Somewhere you are adding the same component twice (for form as well as for container) i guess.
    Regards,
    Harsha

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: LWUIT Form with multiple Components

    Quote Originally Posted by pavanragi View Post
    Hi harsha

    I've modified my code like you said,Here is the Code:



    But ,i am getting the Exception:
    Check your entire code once again . Lwuit will not allow any component to be add twice to a container . Even form is derived from container
    so if you are adding the component to a container make sure you dont add it to a form .
    Regards,
    Venkatesh

  6. #6
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Re: LWUIT Form with multiple Components

    Create a Form object and set the Boxlayout Y-axis like this:

    form2 = new Form();
    form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

    and add all the components one by one to the form reference:


    form2.addComponent(title);
    form2.addComponent(pubDate);
    form2.addComponent(icon);
    form2.addComponent(textarea);
    form2.show();
    Last edited by pavanragi; 2012-10-15 at 12:57.

Similar Threads

  1. How to append LWUIT List screen to a LWUIT Form in j2me?
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-08-06, 07:01
  2. Translate from LCDUI form to LWUIT UI Form
    By debasish_cse05 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2011-02-02, 11:37
  3. pass Text field value from one form to another form in LWUIT.
    By debasish_cse05 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2011-01-13, 11:21
  4. problem in back and forth of LWUIT form and normal form in j2me
    By jugal.inani in forum Mobile Java General
    Replies: 8
    Last Post: 2010-06-09, 12:24
  5. LWUIT accessing components within forms
    By dschmider in forum Mobile Java General
    Replies: 1
    Last Post: 2010-02-21, 23:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×