The container is a control that contains child controls. It is possible to adjust its transparency, screen transition effects, borders and background style.
If you want to know more about how differences between windows and container, how to navigate between interfaces and what are the best ways to handle containers and windows, just click on the link below:
{% page-ref page="../../guides/app-architecture/container-x-window.md" %}
{% code title="Container" %}
class ContainerSample extends Container{
@Override
public void initUI() {
try {
ImageControl logo = new ImageControl(new Image("path_of_your_logo_img"));
logo.scaleToFit = true;
logo.centerImage = true;
logo.transparentBackground = true;
add(logo, CENTER, CENTER, PARENTSIZE + 50, PARENTSIZE + 50);
} catch (ImageException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
{% endcode %}
- ****How to navigate between screens****
- Container characteristics are assigned to child controls
Some methods that are most commonly used
name | Description |
---|---|
add(Control control, int x, int y, int w, int h, Control relative);
|
Adds the control on the screen where the parameter x is the positioning of the control in the container in relation to the x axis, the parameter y is the positioning of the control in the container in relation to the y axis, parameter w is the length of the component, parameter h represents the height of the component and the relative parameter is to change the reference of the control to add on the screen (by default the relative is the last control added). |
setBackForeColors(Color back, Color fore) | Assigns the color of the back parameter to the container background and the color of the fore parameter to the forecolor of the container. It is interesting to remember that the children of the container inherit the characters of the same. |
setBackColor(Color back);
|
Assigns the color of the back parameter to the container background |
You can see more information in javaDoc