public class GenericListCellRenderer<T> extends Object implements ListCellRenderer<T>, CellRenderer<T>
The generic list cell renderer can display containers or arbitrary Codename One components
as items in a list, notice that
we strongly
discourage usage of lists.. It relies on the source data being a Map
object. It extracts values from
the Map
using the component name as an indication to the Map key lookup.
This renderer supports label tickering, check boxes/radio buttons etc. seamlessly.
Please notice that you must use at least two distinct instances of the component
when passing them to the constructor, reusing the same instance WILL NOT WORK!
Furthermore, the renderer instance cannot be reused for multiple lists, each list will need
a new instance of this renderer!
Sample usage for this renderer follows:
Modifier and Type | Field and Description |
---|---|
static String |
ENABLED
If this flag exists in a Map of data the renderer will enable/disable
the entries, the flag assumes either Boolean.TRUE or Boolean.FALSE.
|
static String |
SELECT_ALL_FLAG
Put this flag as a Map key to indicate that a checkbox entry rendered by
this renderer should act as a "select all" entry and toggle all other entries.
|
Constructor and Description |
---|
GenericListCellRenderer(Component selected,
Component unselected)
Constructs a generic renderer with the given selected/unselected components
|
GenericListCellRenderer(Component odd,
Component oddUnselected,
Component even,
Component evenUnselected)
Constructs a generic renderer with the given selected/unselected components for
odd/even values allowing a "pinstripe" effect
|
Modifier and Type | Method and Description |
---|---|
Button |
extractLastClickedComponent()
Allows partitioning the renderer into "areas" that can be clicked.
|
URLImage.ImageAdapter |
getAdapter()
The adapter used when dealing with image URL's
|
Component |
getCellRendererComponent(Component list,
Object model,
T value,
int index,
boolean isSelected)
Returns a component instance that is already set to render "value".
|
static URLImage.ImageAdapter |
getDefaultAdapter()
The default adapter to use for image URLs
|
Component |
getFocusComponent(Component list)
Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling.
|
Component |
getListCellRendererComponent(List list,
T value,
int index,
boolean isSelected)
Returns a component instance that is already set to render "value".
|
Component |
getListFocusComponent(List list)
Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling.
|
Component |
getSelected() |
Component |
getSelectedEven() |
Component |
getUnselected() |
Component |
getUnselectedEven() |
boolean |
isFisheye()
In fisheye rendering mode the renderer maintains selected component drawing
|
boolean |
isSelectionListener() |
void |
setAdapter(URLImage.ImageAdapter adapter)
The adapter used when dealing with image URL's
|
static void |
setDefaultAdapter(URLImage.ImageAdapter aDefaultAdapter)
The default adapter to use for image URLs
|
void |
setFisheye(boolean fisheye)
In fisheye rendering mode the renderer maintains selected component drawing
|
void |
setSelectionListener(boolean selectionListener) |
void |
updateIconPlaceholders()
Updates the placeholder instances, this is useful for changing the URLImage placeholder in runtime as
might happen in the designer
|
public static final String ENABLED
public static final String SELECT_ALL_FLAG
public GenericListCellRenderer(Component selected, Component unselected)
selected
- indicates the selected value for the rendererunselected
- indicates the unselected value for the rendererpublic GenericListCellRenderer(Component odd, Component oddUnselected, Component even, Component evenUnselected)
odd
- indicates the selected value for the rendereroddUnselected
- indicates the unselected value for the renderereven
- indicates the selected value for the rendererevenUnselected
- indicates the unselected value for the rendererpublic static URLImage.ImageAdapter getDefaultAdapter()
public static void setDefaultAdapter(URLImage.ImageAdapter aDefaultAdapter)
aDefaultAdapter
- the defaultAdapter to setpublic void updateIconPlaceholders()
public Button extractLastClickedComponent()
public Component getCellRendererComponent(Component list, Object model, T value, int index, boolean isSelected)
getCellRendererComponent
in interface CellRenderer<T>
list
- the list componentmodel
- the model behind the rendervalue
- the value to renderindex
- the index in the listisSelected
- whether the entry is selectedpublic Component getListCellRendererComponent(List list, T value, int index, boolean isSelected)
getListCellRendererComponent
in interface ListCellRenderer<T>
list
- the list componentvalue
- the value to renderindex
- the index in the listisSelected
- whether the entry is selectedpublic Component getListFocusComponent(List list)
getListFocusComponent
in interface ListCellRenderer<T>
list
- the parent listComponent.setSmoothScrolling(boolean)
public Component getFocusComponent(Component list)
getFocusComponent
in interface CellRenderer<T>
list
- the parent listComponent.setSmoothScrolling(boolean)
public boolean isSelectionListener()
public void setSelectionListener(boolean selectionListener)
selectionListener
- the selectionListener to setpublic Component getSelected()
public Component getUnselected()
public Component getSelectedEven()
public Component getUnselectedEven()
public boolean isFisheye()
public void setFisheye(boolean fisheye)
fisheye
- the fisheye to setpublic URLImage.ImageAdapter getAdapter()
public void setAdapter(URLImage.ImageAdapter adapter)
adapter
- the adapter to set