Reputation: 51
I have tried changing the background color with getStyle() but it did not quite work, even though changing the color worked.
Heres my code:
public class HomeUi extends VerticalLayout {
public HomeUi(){
this.setSizeFull();
HorizontalLayout back = new HorizontalLayout();
back.setSizeFull();
back.getStyle().set("background","red");
back.getStyle().set("color","blue");
back.add(new Paragraph("HELLO BEAUTIFUL WORLD!"));
this.add(back);
}
}
Upvotes: 0
Views: 1115
Reputation: 2064
The following works:
back.getStyle().set("background-color","red");
Upvotes: 2
Reputation: 51
The issue was that I used Vaadin in compability mode. I upgraded the Vaadin version to 23 and removed compability mode and then changing the color worked fine.
Upvotes: 0
Reputation: 1761
I just tested your code and it works as you expected. I got red background with blue text.
@Slf4j
@PageTitle("test")
@Route(value = "test", layout = MainLayout.class)
public class TestView extends VerticalLayout {
public TestView() {
this.setSizeFull();
HorizontalLayout back = new HorizontalLayout();
back.setSizeFull();
back.getStyle().set("background","red");
back.getStyle().set("color","blue");
back.add(new Paragraph("HELLO BEAUTIFUL WORLD!"));
this.add(back);
}
}
Result
Upvotes: 0