# ImageList

### Overview

This control will have a list of images that will be displayed&#x20;

![](/files/-LeyrJqbpKUUf-3V1HPy)

### Source Code

{% code title="Example Code" %}

```java
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

* See the [Java Docs](https://rs.totalcross.com/doc/totalcross/ui/ImageList.html) for more information.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.totalcross.com/documentation/components/imagelist.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
