Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:57:07+00:00 2026-06-01T07:57:07+00:00

Situation:- In my code I have to use the LWUIT Component object for the

  • 0

Situation:-

In my code I have to use the LWUIT Component object for the listview controls. The controls are dynamic and hence can be in any number.
Right now I am creating Component objects according to the controls(in numbers) i.e.- for every control to be created first the Component object is creating.
This process slows down the rendering of the listview when the controls are increasing.

Solution:-

If I create the Component object and use it in a loop for all the controls it is taking the reference of the object and hence displays all the listview items(controls) with the same data.
Now I am able to think of one last option of Cloning my object and using it to create the controls.

Problem:-

But I can’t find any way in LWUIT by which I can achieve the copying of object.

What can be the alternatives in LWUIT to solve this problem?

P.S.-The listview items are of same type, but with different data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:57:09+00:00Added an answer on June 1, 2026 at 7:57 am

    Use a List component and the Renderer design pattern to create a “rubber stamp” component where you can display a large number of elements easily. See an explanation of this in the Codename One blog.

    Create these classes first :

    public class ListUtil {
    
        private Vector data = new Vector();
        private Content[] contents;
    
        public ListUtil(Vector vData)
        {
            data = vData;
            contents = new Content[vData.size()];
        }
    
        public List createList(Display display, CListCell renderer, ActionListener listener)
        {
            CList theList;
            for(int i = 0; i < data.size(); i++)
            {
                contents[i] = new Content(String.valueOf(data.elementAt(i)));
            }
            theList = new CList(display, contents, renderer, listener);
            return theList;
        }
    }
    
    public class Content
    {
        private String  row;
    
        public Content(String row)
        {
            this.row = row;
        }
    
        public String getRow()
        {
            return (row);
        }
    }
    
    public class CListCell extends Container implements ListCellRenderer {
    
        private Label focus = new Label("");
    
        public CListCell()
        {
            super();
            // create and add the components here among the components which will display data
        }
        public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected)
        {
            Content entry = null;
            if (value instanceof Content)
                entry = (Content)value;
            componentDisplayingDataAddedIntoThisListCellRenderer.setText(entry.getRow());
            return this;
        }
        public Component getListFocusComponent(List arg0)
        {
            return focus;
        }
    }
    
    public class CList extends List {
        private Display disp;
        public CList(Display display, Object[] data, CListCell renderer, ActionListener actionListener)
        {
            super(data);
            setListCellRenderer(renderer);
            setIgnoreFocusComponentWhenUnfocused(true);
            addActionListener(actionListener);
            setScrollAnimationSpeed(getScrollAnimationSpeed()/4);
            disp = display;
        }
        public void pointerReleased(int x,int y)
        {
            if (isEnabled() && hasFocus())
                super.pointerReleased(x, y);
        }
        public void keyReleased(int keyCode)
        {
            if (isEnabled() && hasFocus())
            {
                if (disp.getGameAction(keyCode) == Display.GAME_FIRE)
                    pointerReleased(getX(),getY());
                else
                    super.keyReleased(keyCode);
            }
        }
    }
    

    To create your List and add it to a Form :

    public class myForm extends Form implements ActionListener
    {
        private Vector listSource = // your vector of data
        private CListCell renderer = new CListCell();
        private List theList = (new ListUtil(listSource)).createList(Display.getInstance(),renderer, this);
        ...
        public void actionPerformed(ActionEvent evt)
        {
           if (evt.getSource() == theList)
                doSomething();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation: We have some generic graphics code that we use for one
I don't have the code available right now, but I'll describe my situation and
I have the following situation in code, which I suspect may be a bit
I have recently come across a situation where code is dynamically loading some libraries,
I have a situation where I want certain code to be executed no matter
I have encountered a weird situation while updating/upgrading some legacy code. I have a
I'm wondering what is the culturally-acceptable way to handle this code situation. I have
Basically the situation is like this (simplified, pseudo code): I have 2 TABLES person
I have a data situation where I want to use an index path. As
The situation: We have a library project that houses much of our code for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.