Class AbstractBorder
- All Implemented Interfaces:
Serializable, Border
- Direct Known Subclasses:
BevelBorder, CompoundBorder, EmptyBorder, EtchedBorder, LineBorder, TitledBorder
AbstractBorder — base class for every
concrete border in this package plus the extension point user code
subclasses for custom borders.
Adds a browser-side applyCss(com.vaadin.flow.dom.Element)
template method on top of Swing's paint-only contract. Concrete borders
override it to write the CSS representation of themselves onto the
target element; vaadinx's JComponent.setBorder(Border)
calls into that hook, so user code that writes
panel.setBorder(new LineBorder(Color.BLACK)) sees the line
actually render in the browser.
Custom user borders extending AbstractBorder without
overriding applyCss won't render (R_best_effort_behaviour best-effort) — the base
default clears any previously-installed border CSS and writes nothing.
paintBorder(Component, Graphics, int, int, int, int) + getBorderInsets(Component) still work as on real
Swing, so server-side code that reads insets or drives paint onto a
Graphics sink keeps behaving the same.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyCss(com.vaadin.flow.dom.Element element) Write this border's CSS onto the target element.static voidclearBorderCss(com.vaadin.flow.dom.Element element) Remove every border-related inline style key that a concrete border from this package might have written.getBorderInsets(Component c, Insets insets) Fill-the-arg variant of getBorderInsets — concrete borders override when they want to avoid the Insets allocation.booleanvoidpaintBorder(Component c, Graphics g, int x, int y, int width, int height)
-
Constructor Details
-
AbstractBorder
public AbstractBorder()
-
-
Method Details
-
paintBorder
- Specified by:
paintBorderin interfaceBorder
-
getBorderInsets
- Specified by:
getBorderInsetsin interfaceBorder
-
getBorderInsets
Fill-the-arg variant of getBorderInsets — concrete borders override when they want to avoid the Insets allocation. Default readsgetBorderInsets(vaadinx.awt.Component)and copies. -
isBorderOpaque
public boolean isBorderOpaque()- Specified by:
isBorderOpaquein interfaceBorder
-
applyCss
public void applyCss(com.vaadin.flow.dom.Element element) Write this border's CSS onto the target element. Called byJComponent.setBorder(Border). Concrete border classes override to emit the CSS that represents them (padding for EmptyBorder,borderfor LineBorder, per-side for MatteBorder, …). The base implementation clears any previously-installed border CSS viaclearBorderCss(Element)and writes nothing, which is the honest behaviour for a user-authored custom AbstractBorder that didn't override this hook.Typical override:
clearBorderCss(e); set("border", …);. Always clear first so a previous border's keys don't linger. -
clearBorderCss
public static void clearBorderCss(com.vaadin.flow.dom.Element element) Remove every border-related inline style key that a concrete border from this package might have written. Called by bothJComponent.setBorder(Border)(when the new border is null or custom) and every concrete border'sapplyCss(Element)before it writes its own keys.The whitelist covers the shorthand
border, per-sideborder-top/right/bottom/leftand their width/style/color longhands,border-radius, andpadding+ its four longhands. If a user also wrote one of these inline styles manually, it's cleared too —setBorderowns these CSS properties on a container.
-