Package com.storedobject.vaadin
Class Box
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.Component>
com.storedobject.vaadin.Box
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,Serializable
@CssImport("./so/hover/styles.css")
public class Box
extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.Component>
Using this class one can draw a "box" around any Vaadin component. If you have a component, in order to enclose it in a box, just use
new Box(component). Box is drawn as per "HTML Box Model".- Author:
- Syam
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBox(com.vaadin.flow.component.Component component) Put a component inside a box. -
Method Summary
Modifier and TypeMethodDescriptionvoidAlign the box in such way that total width/height of the box will be same as component's width/height.com.vaadin.flow.component.Componentvoidgrey()Create a grey background style.protected com.vaadin.flow.component.ComponentvoidsetBorderColor(String color) Set border color.voidsetBorderRadius(int radius) Set border radius.voidsetBorderStyle(String style) Set border style.voidsetBorderWidth(int widthInPixels) Set border width.voidsetBorderWidth(String widths) Set border width.voidsetEnabled(boolean enabled) Set enabled/disabled style.voidsetHiliteOnHover(boolean hilite) Hilite the content on hover by making the background to "var(--lumo-primary-color-50pct)".voidsetMargin(int margin) Set margin.voidSet margin.voidsetPadding(int padding) Set padding.voidsetPadding(String paddings) Set padding.voidsetReadOnly(boolean readOnly) Set read only style.voidDirectly set styles.Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
Box
public Box(com.vaadin.flow.component.Component component) Put a component inside a box. Default behaviour of the box:Border style: solid, Border width: 2, Border colour: var(--lumo-contrast-20pct), Padding: 4, Border radius: 5
- Parameters:
component- Component to be boxed.
-
-
Method Details
-
initContent
protected com.vaadin.flow.component.Component initContent()- Overrides:
initContentin classcom.vaadin.flow.component.Composite<com.vaadin.flow.component.Component>
-
getContent
public com.vaadin.flow.component.Component getContent()- Overrides:
getContentin classcom.vaadin.flow.component.Composite<com.vaadin.flow.component.Component>
-
setHiliteOnHover
public void setHiliteOnHover(boolean hilite) Hilite the content on hover by making the background to "var(--lumo-primary-color-50pct)".- Parameters:
hilite- True if needs to be hilited
-
setBorderRadius
public void setBorderRadius(int radius) Set border radius.- Parameters:
radius- Radius in pixels
-
setBorderWidth
public void setBorderWidth(int widthInPixels) Set border width.- Parameters:
widthInPixels- Width in pixels
-
setBorderWidth
-
setBorderColor
-
setBorderStyle
-
setPadding
public void setPadding(int padding) Set padding.- Parameters:
padding- Padding in pixels
-
setPadding
-
setMargin
public void setMargin(int margin) Set margin.- Parameters:
margin- Margin in pixels
-
setMargin
-
setStyle
-
alignSizing
public void alignSizing()Align the box in such way that total width/height of the box will be same as component's width/height. However, margin is still accounted for while computing the size. -
setReadOnly
public void setReadOnly(boolean readOnly) Set read only style. (Vaadin's Lumo theme is emulated).- Parameters:
readOnly- Read only flag
-
setEnabled
public void setEnabled(boolean enabled) Set enabled/disabled style. (Vaadin's Lumo theme is emulated).- Parameters:
enabled- Enabled or not
-
grey
public void grey()Create a grey background style. Same as setting setReadonly(true).
-