Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create your own ListRenderer class.</p> <h2>ListRenderer.java</h2> <pre><code>import com.sun.lwuit.Component; import com.sun.lwuit.Label; import com.sun.lwuit.List; import com.sun.lwuit.list.ListCellRenderer; public class ListRenderer extends Label implements ListCellRenderer { public ListRenderer() { } public Component getListCellRendererComponent(List value, Object obj, int arg2, boolean isSelected) { // TODO Auto-generated method stub Locations listClassObj = (Locations) obj; Label listValue = new Label(listClassObj.Name); return listValue; } public Component getListFocusComponent(List arg0) { // TODO Auto-generated method stub setText(""); setFocus(false); return this; } public void repaint() { } } </code></pre> <h2>Midlet:</h2> <p>then, another method to convert string arrays to List array</p> <pre><code>public ComboBox getList(String[] locations,int[] x,int[] y){ Locations[] locationObjs=new Locations[locations.length]; for(int i=0;i&lt;locations.length;i++){ locationObjs=new Locations(locations[i],x[i],y[i]); } return new ComboBox(locationObjs); } private ComboBox getLocations(){ String[] locations={"landmark1","landmark2","landmark3","landmark4"}; int[] x={23,24,25,26}; int[] y={40,40,40}; ComboBox list=getList(locations,x,y); return list; } </code></pre> <p>then,set it for combobox</p> <pre><code>combobox_locations=getLocations(); combobox_locations.setListCellRenderer(new ListRenderer()); </code></pre> <p>then use, the below code</p> <pre><code>Object item = comboBox_Locations.getSelectedItem(); if (item.getClass() == Locations.class) { String Name = ((Locations)item).Name.toString(); int xCoords = ((Locations)item).getX(); int yCoords = ((Locations)item).getY(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload