Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.59 KB

imagelist.md

File metadata and controls

63 lines (45 loc) · 1.59 KB

ImageList

Overview

This control will have a list of images that will be displayed

Source Code

{% code title="Example Code" %}

import totalcross.io.IOException;
import totalcross.sys.Settings;
import totalcross.ui.ImageList;
import totalcross.ui.MainWindow;
import totalcross.ui.image.Image;
import totalcross.ui.image.ImageException;


public class ImageList extends MainWindow {

    public ImageList(){
        setUIStyle(Settings.Material);
    }

    @Override
    public void initUI() {

        try {
            ImageList imageList = new ImageList();
            imageList.add(new Image("images/logo.png"));
            imageList.add(new Image("images/insta_icon.png"));

            add(imageList, LEFT, TOP);
        } catch (ImageException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

{% endcode %}

{% hint style="warning" %} Do not forget to create a folder called "images" inside /src/main/resources and save the images inside it [images]. {% endhint %}

Methods

Type Name Description
Constructor ImageList() Create a new instance
Constructor ImageList(Object[] items) Create a new instance already with a filled array
int getPreferredWidth() Returns the preferred Width
int getPreferredHeight() Returns the preferred height

References