cadmy cadmy - 5 months ago 87
Java Question

How to output label with icon in line?

Text of the label jumps on a next line when I use

setIcon()
. How to output it in one line?

Label info = new Label("Reports are generated every day at 5 pm", ContentMode.HTML);
info.setIcon( new ThemeResource("img/icons/information.png") ) ;
info.setSizeUndefined();
JobsLayout.addComponent( info );
JobsLayout.setComponentAlignment(info, Alignment.MIDDLE_RIGHT);

Answer

You can use icon inside label text:

Label date = new Label(FontAwesome.CALENDAR.getHtml() + " " + new Date());
date.setContentMode(ContentMode.HTML);

Source: Vaadin Wiki.

Result:

Vaadin label with icon in the same line.