I would like to programmatically set a border around a Form component in Java. How can I do this without having to edit the css style sheet?
Style::set
to specify CSSIn Vaadin Flow (Vaadin versions 10 and later), you can conveniently set CSS for a widget or layout programmatically. No need to edit separate CSS files, even though styling with CSS files is the recommended way.
Style
object, call set to pass the name and value of your CSS property.For example, I find setting a bright colored border on my nested layouts quite helpful for debugging.
myVerticalLayout.getStyle().set( "border" , "6px dotted DarkOrange" ) ;
You can see this in action with this screenshot on my Answer to another Vaadin question here: