THIS
- Self-referential generic THISpublic interface FluentComponent<THIS extends FluentComponent<THIS>> extends com.vaadin.ui.Component, FluentSizeable<THIS>
Component
Component
Modifier and Type | Interface and Description |
---|---|
static interface |
FluentComponent.FluentFocusable<C extends FluentComponent.FluentFocusable<C>>
A
Focusable complemented by fluent setters. |
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
Modifier and Type | Method and Description |
---|---|
default THIS |
withCaption(String caption)
Sets the caption of the component.
|
default THIS |
withEnabled(boolean enabled)
Enables or disables the component.
|
default THIS |
withIcon(com.vaadin.server.Resource icon)
Sets the icon of the component.
|
default THIS |
withId(String id)
Adds an unique id for component that is used in the client-side for
testing purposes.
|
default THIS |
withParent(com.vaadin.ui.HasComponents parent)
Sets the parent connector of the component.
|
default THIS |
withPrimaryStyleName(String style)
Changes the primary style name of the component.
|
default THIS |
withStyleName(String... styles)
Adds one or more style names to this component by using one or multiple
parameters.
|
default THIS |
withStyleName(String style)
Sets one or more user-defined style names of the component, replacing any
previous user-defined styles.
|
default THIS |
withVisible(boolean visible)
Sets the visibility of the component.
|
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
withFullHeight, withFullSize, withFullWidth, withHeight, withHeight, withSize, withUndefinedHeight, withUndefinedSize, withUndefinedWidth, withWidth, withWidth
default THIS withCaption(String caption)
A caption is an explanatory textual label accompanying a user
interface component, usually shown above, left of, or inside the
component. Icon (see setIcon()
is
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"); area.setValue("<h1>Helpful Heading</h1>" + "<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 FormLayout
component 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
Button
and Panel
, manage the caption themselves and
display it inside the component.
A reimplementation should call the superclass implementation.
caption
- the new caption for the component. If the caption is
null
, no caption is shown and it does not normally
take any spaceComponent.setCaption(java.lang.String)
default THIS withEnabled(boolean enabled)
Button enabled = new Button("Enabled"); enabled.setEnabled(true); // The default layout.addComponent(enabled); Button disabled = new Button("Disabled"); disabled.setEnabled(false); layout.addComponent(disabled);
enabled
- a boolean value specifying if the component should be enabled
or notComponent.setEnabled(boolean)
default THIS withIcon(com.vaadin.server.Resource icon)
An icon is an explanatory graphical label accompanying a user interface
component, usually shown above, left of, or inside the component. Icon is
closely related to caption (see setCaption()
)
and is usually displayed horizontally before or after it, depending on
the component and the containing layout.
The image is loaded by the browser from a resource, typically a
ThemeResource
.
// Component with an icon from a custom theme TextField name = new TextField("Name"); name.setIcon(new ThemeResource("icons/user.png")); layout.addComponent(name); // Component with an icon from another theme ('runo') Button ok = new Button("OK"); ok.setIcon(new ThemeResource("../runo/icons/16/ok.png")); layout.addComponent(ok);
The icon 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 icons
left-aligned above the contained components, while the FormLayout
component shows the icons on the left side of the vertically laid
components, with the icons and their associated components left-aligned
in their own columns. The CustomComponent
does not manage the
icon of its composition root, so if the root component has an icon, it
will not be rendered.
An icon will be rendered inside an HTML element that has the
v-icon
CSS style class. The containing layout may enclose an icon
and a caption inside elements related to the caption, such as
v-caption
.
icon
- the icon of the component. If null, no icon is shown and it
does not normally take any space.Component.setIcon(com.vaadin.server.Resource)
,
Component.setCaption(String)
default THIS withId(String id)
id
- An alphanumeric idComponent.setId(java.lang.String)
default THIS withPrimaryStyleName(String style)
The primary style name identifies the component when applying the CSS theme to the Component. By changing the style name all CSS rules targeted for that style name will no longer apply, and might result in the component not working as intended.
To preserve the original style of the component when changing to a new primary style you should make your new primary style inherit the old primary style using the SASS @include directive. See more in the SASS tutorials.
style
- The new primary style nameComponent.setPrimaryStyleName(java.lang.String)
default THIS withStyleName(String style)
Label label = new Label("This text has a lot of style"); label.setStyleName("myonestyle myotherstyle");
Each style name will occur in two versions: one as specified and one that
is prefixed with the style name of the component. For example, if you
have a Button
component and give it "mystyle
" style, the
component will have both "mystyle
" and "v-button-mystyle
"
styles. You could then style the component either with:
.myonestyle {background: blue;}
or
.v-button-myonestyle {background: blue;}
It is normally a good practice to use addStyleName()
rather than this setter, as different software
abstraction layers can then add their own styles without accidentally
removing those defined in other layers.
style
- the new style or styles of the component as a space-separated
listComponent.getStyleName()
,
Component.addStyleName(String)
,
Component.removeStyleName(String)
default THIS withStyleName(String... styles)
styles
- the style name or style names to be added to the componentComponent.addStyleName(String)
,
Component.setStyleName(String)
,
Component.removeStyleName(String)
default THIS withVisible(boolean visible)
Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.
TextField readonly = new TextField("Read-Only"); readonly.setValue("You can't see this!"); readonly.setVisible(false); layout.addComponent(readonly);
A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.
visible
- the boolean value specifying if the component should be
visible after the call or not.Component.setVisible(boolean)
,
Component.isVisible()
default THIS withParent(com.vaadin.ui.HasComponents parent)
This method automatically calls Component.attach()
if the component
becomes attached to the session, regardless of whether it was attached
previously. Conversely, if the component currently is attached to the
session, ClientConnector.detach()
is called for the connector before attaching
it to a new parent.
This method is rarely called directly.
ComponentContainer.addComponent(Component)
or a
HasComponents
specific method is normally used for adding
components to a parent and the used method will call this method
implicitly.
parent
- the parent connectorIllegalStateException
- if a parent is given even though the connector already has a
parentComponent.setParent(HasComponents)
Copyright © 2017 Jean-Christophe Fortier. All rights reserved.