Class ContainerList

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class ContainerList extends Container
This is a "list component" implemented as a container with a layout manager which provides some of the ui advantages of a Container and some of a list while pulling out some of the drawbacks of both. This container uses the model/renderer approach for populating itself, adding/removing entries will probably break it. It still provides most of the large size advantages a list offers since the components within it are very simple and don't contain any actual state other than layout information. The big advantage with this class is the ability to leverage elaborate CodenameOne layouts such as Grid, Table & flow layout to provide other ways of rendering the content of a list model.
  • Constructor Details

    • ContainerList

      public ContainerList()
      Default constructor
    • ContainerList

      public ContainerList(ListModel m)

      Constructs a container list with the given model

      Parameters
      • m: the model
    • ContainerList

      public ContainerList(Layout l, ListModel m)

      Constructs a container list with the given model and layout

      Parameters
      • l: layout manager

      • m: the model

  • Method Details

    • getRenderer

      public CellRenderer getRenderer()
      The renderer used to draw the container list elements
    • setRenderer

      public void setRenderer(CellRenderer r)

      The renderer used to draw the container list elements

      Parameters
      • r: renderer instance
    • getModel

      public ListModel getModel()

      Returns the list model

      Returns

      the list model

    • setModel

      public void setModel(ListModel model)

      Set the model for the container list

      Parameters
      • model: a model class that is mapped into the internal components
    • addActionListener

      public void addActionListener(ActionListener l)

      Allows binding a listener to user selection actions

      Parameters
      • l: the action listener to be added
    • getActionListeners

      public Vector getActionListeners()

      This method allows extracting the action listeners from the current list

      Returns

      vector containing the action listeners on the list

      Deprecated

      use getListeners instead

    • getListeners

      public Collection getListeners()

      This method allows extracting the action listeners from the current list

      Returns

      Collection containing the action listeners on the list

    • removeActionListener

      public void removeActionListener(ActionListener l)

      Allows binding a listener to user selection actions

      Parameters
      • l: the action listener to be removed
    • initComponent

      protected void initComponent()
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • deinitialize

      protected void deinitialize()
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
      Overrides:
      deinitialize in class Component
    • getSelectedItem

      public Object getSelectedItem()

      Returns the current/last selected item

      Returns

      selected item or null

    • getSelectedIndex

      public int getSelectedIndex()

      Returns the current selected offset in the list

      Returns

      the current selected offset in the list

    • setSelectedIndex

      public void setSelectedIndex(int index)

      Sets the current selected offset in the list, by default this implementation will scroll the list to the selection if the selection is outside of the screen

      Parameters
      • index: the current selected offset in the list
    • fireActionEvent

      protected void fireActionEvent(ActionEvent evt)

      Triggers the event to the listeners

      Parameters
      • evt: the event to fire
    • getPropertyNames

      public String[] getPropertyNames()

      A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

      Returns

      the property names allowing mutation

      Overrides:
      getPropertyNames in class Component
    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

      Overrides:
      getPropertyTypes in class Component
    • getPropertyTypeNames

      public String[] getPropertyTypeNames()

      This method is here to workaround an XMLVM array type bug where property types aren't identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer

      Returns

      Array of type names

      Overrides:
      getPropertyTypeNames in class Component
    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

      Overrides:
      getPropertyValue in class Component
    • setPropertyValue

      public String setPropertyValue(String name, Object value)

      Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

      Overrides:
      setPropertyValue in class Component
    • getSelectedRect

      public Rectangle getSelectedRect()
      Description copied from class: Component

      Returns the component bounds with absolute screen coordinates, for components that include an internal selection behavior and are not containers (currently only List) this method allows returning the position of the selection itself which is useful for things such as the popup dialog and similar UI's that need to reference the position of the selection externally

      Returns

      the bounds of the component with absolute screen coordinates

      Overrides:
      getSelectedRect in class Component
    • getDragRegionStatus

      protected int getDragRegionStatus(int x, int y)

      Indicates if the section within the X/Y area is a "drag region" where we expect people to drag or press in which case we can instantly start dragging making perceived performance faster. This is invoked by the implementation code to optimize drag start behavior

      Parameters
      • x: x location for the touch

      • y: y location for the touch

      Returns

      one of the DRAG_REGION_* values

      Overrides:
      getDragRegionStatus in class Component