Sets the caption of the component.
A caption is an explanatory textual label accompanying a user
interface component, usually shown above, left of, or inside the
component. Icon (see
closely related to caption and is usually displayed horizontally before
or after it, depending on the component and the containing layout.
The caption can usually also be given as the first parameter to a
constructor, though some components do not support it.
RichTextArea area = new RichTextArea();
area.setCaption("You can edit stuff here");
+ "<p>All this is for you to edit.</p>");
The contents of a caption are automatically quoted, so no raw HTML can be
rendered in a caption. The validity of the used character encoding,
usually UTF-8, is not checked.
The caption of a component is, by default, managed and displayed by the
layout component or component container in which the component is placed.
For example, the
VerticalLayout component shows the captions
left-aligned above the contained components, while the
FormLayoutcomponent shows the captions on the left side of the vertically laid
components, with the captions and their associated components
left-aligned in their own columns. The
CustomComponent does not
manage the caption of its composition root, so if the root component has
a caption, it will not be rendered. Some components, such as
Panel, manage the caption themselves and
display it inside the component.