Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Sorting CSS Layout alphabetically
Hey Guys,
I just made my first vaadin app and I try to use the CssLayout. I created a Website with a sidebar. For each menu in the sidebar I use an CssLayout Object.
These Objects contain a lot of NativeButtons. Is there a way to oder these Buttons alphabetically by name?
I imagine something like this:
private CssLayout test;
private NativeButton button1;
private NativeButton button2;
private void initTest() {
button1 = new NativeButton("button1");
test.addComponent(button1);
button2 = new NativeButton("button2");
test.addComponent(button2);
// the function I'm looking for should be something like this
test.sort();
}
Is there anything like that?
Cheers Rolfe
There is not really any way to implement a generic sort() on a layout (should it sort by type (buttons, labels, ...), by name, by size, ...) so it is left to you to do the sort yourself.
Components in a layout are displayed in the order of addComponent() so if you build the layout in the right order, the output will be sorted.