Multiple Div Component

In my Java spring-boot project i want to add some features like multiple news section.(demo picture given below).
I found a free API and i want to collect news from them.But which components help me out for set those news by multiple section and separately??
Any expert can help me out? Thanks in advance.

17522904.png

Hi and sorry for the late response!

You can stack components vertically inside a VerticalLayout. To create dividers between each component like in your example, you could use the Hr component.

So you could do something like this:

VerticalLayout layout = new VerticalLayout();
layout.add(new H1("LATEST NEWS"));

for (String news : allNews) {
    layout.add(new Paragraph(news));
    layout.add(new Hr());
}

Another option would be to use CSS to add borders to each component.

Pekka Maanpää:
Hi and sorry for the late response!

You can stack components vertically inside a VerticalLayout. To create dividers between each component like in your example, you could use the Hr component.

So you could do something like this:

VerticalLayout layout = new VerticalLayout();
layout.add(new H1("LATEST NEWS"));

for (String news : allNews) {
    layout.add(new Paragraph(news));
    layout.add(new Hr());
}

Another option would be to use CSS to add borders to each component.

I already solved it but as a new learner i made it complex. Now you makes it cool.Tnx dude

I got a problem that i have two layout.Like this:
But left sided layout height is too short than right side layout.Because left sided total news than right sided news. How can i set same height for this two layouts if news numbers are less than one another.
17554700.png

Try left.setSizeFull().