-2
for (Evenement r : list) {
    Container c3 = new Container(new FlowLayout());
    Image placeholder = Image.createImage(380, 380);
    EncodedImage enc = EncodedImage.createFromImage(placeholder, false);
    URLImage urlim = URLImage.createToStorage(enc, r.getImg(), url + "/" + r.getImg());
    ImageViewer imgV = new ImageViewer();
    imgV.setImage(urlim);
    SpanLabel cat= new SpanLabel("Nom de l'evenement :" + r.getNom());
    SpanLabel cat6= new SpanLabel(" " );
    Label lab= new Label("jjj");
    c3.add(imgV);
    c3.add(cat6);
    add(lab);

Images display in FlowLayout but I want to add some text under every image. When I add a label with text in it, it appears to the right of the image. Even when I used another Container and put in the label, nothing is changed.
Thanks in advance.

Just another question: Is it possible to Itext PDF API which I have already used in java, before.

Abra
  • 19,142
  • 7
  • 29
  • 41
  • Sorry about people closing the question. They should be more welcoming to new users here. If I understand correctly you need to nest containers by creating a Box Y container with the image and text then add **that** to `c3`. Instead of your `c3.add` methods do: `c3.add(BoxLayout.encloseY(imgV, lab));`. As a side note, notice that you shouldn't use flow layout for things of this type as it's pretty flaky. – Shai Almog May 09 '22 at 01:46

1 Answers1

0

You need to nest containers by creating a BoxLayout container on the Y_AXIS with the image and text then add that to c3.

Instead of:

c3.add(imgV);
c3.add(cat6);

Do:

c3.add(BoxLayout.encloseY(imgV, lab)); 

As a side note, notice that you shouldn't use FlowLayout for things of this type as it's pretty flaky.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65