Package totalcross.ui

Class ImageList

  • All Implemented Interfaces:
    Scrollable

    public class ImageList
    extends ListBox
    Implements a ListBox where the items are images. Next an example of how to use this class as a combobox color chooser:
     ImageList list = new ImageList();
     list.add( ADD AT LEAST ONE IMAGE SO THE CORRECT SIZE CAN BE COMPUTED );
     add(foreCombo = new ComboBox(list), CENTER, BOTTOM);
     
    If you don't add at least one image before calling add/setRect, you must compute the preferred size yourself.
    • Constructor Detail

      • ImageList

        public ImageList()
      • ImageList

        public ImageList​(java.lang.Object[] items)
    • Method Detail

      • drawItem

        protected void drawItem​(Graphics g,
                                int index,
                                int dx,
                                int dy)
        Description copied from class: ListBox
        You can extend ListBox and overide this method to draw the items
        Overrides:
        drawItem in class ListBox
      • drawSelectedItem

        protected void drawSelectedItem​(Graphics g,
                                        int index,
                                        int dx,
                                        int dy,
                                        int w)
        Description copied from class: ListBox
        You can extend ListBox and overide this method to draw the items
        Overrides:
        drawSelectedItem in class ListBox
      • drawCursor

        protected void drawCursor​(Graphics g,
                                  int sel,
                                  boolean on)
        Description copied from class: ListBox
        This method is used to draw the cursor around the desired item
        Overrides:
        drawCursor in class ListBox
      • getPreferredWidth

        public int getPreferredWidth()
        Description copied from class: ListBox
        Returns the preferred width, ie, the size of the largest item plus the size of the scrollbar.
        Overrides:
        getPreferredWidth in class ListBox
      • getPreferredHeight

        public int getPreferredHeight()
        Description copied from class: ListBox
        Returns the number of items multiplied by the font metrics height
        Overrides:
        getPreferredHeight in class ListBox
      • getItemWidth

        protected int getItemWidth​(int index)
        Description copied from class: ListBox
        Returns the width of the given item index with the current fontmetrics. Note: if you overide this class you must implement this method.
        Overrides:
        getItemWidth in class ListBox
      • getItemHeight

        protected int getItemHeight​(int index)
        Overrides:
        getItemHeight in class ListBox