Class BorderCss
java.lang.Object
com.vaadin.swingbridge.surrogates.util.BorderCss
Border ↔ CSS conversion for the surrogate
JComponentMixin.setBorder /
getBorder path: applyBorderCss(Element, Border) writes a JDK Border as
inline CSS, borderFromCss(Element) reconstructs the closest Border
back (lossy per SD_border_css_lossy). Includes the TitledBorder pseudo-element
rendering, whose one-off ::before rule is injected per UI via the
generic VaadinUtils.injectStyleOnce(UI, String, String, String) primitive.
Color conversion delegates to CssConvert. Shared with
:emulators in the SD_shelper_statics-allowed direction — the emulator
vaadinx.swing.border.TitledBorder calls
ensureTitledBorderStyleInjected(UI) directly.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyBorderCss(com.vaadin.flow.dom.Element element, Border border) Write the CSS representation ofborderontoelement.static BorderborderFromCss(com.vaadin.flow.dom.Element element) Reconstruct the closest JDKBorderfrom the CSS currently written onelement.static voidclearBorderCss(com.vaadin.flow.dom.Element element) Remove every border-related CSS key we might have written, plus thedata-emul-border-titleattribute thatapplyBorderCss(Element, Border)writes forTitledBorder.static voidensureTitledBorderStyleInjected(com.vaadin.flow.component.UI ui) Ensure the[data-emul-border-title]::beforerule is installed on the current page (and stays installed across@PreserveOnRefreshreloads).
-
Method Details
-
clearBorderCss
public static void clearBorderCss(com.vaadin.flow.dom.Element element) Remove every border-related CSS key we might have written, plus thedata-emul-border-titleattribute thatapplyBorderCss(Element, Border)writes forTitledBorder. Used before each write, and onsetBorder(null). -
ensureTitledBorderStyleInjected
public static void ensureTitledBorderStyleInjected(com.vaadin.flow.component.UI ui) Ensure the[data-emul-border-title]::beforerule is installed on the current page (and stays installed across@PreserveOnRefreshreloads). Thin wrapper overVaadinUtils.injectStyleOnce(UI, String, String, String); no-op when no UI is current. -
applyBorderCss
Write the CSS representation ofborderontoelement. Dispatches by runtime type across the JDK border hierarchy:LineBorder→border: Npx solid color(+ optionalborder-radius).EmptyBorder→padding.MatteBorder(color-only) → four per-sideborder-Xlonghands.BevelBorder/SoftBevelBorder→border: 2px inset|outset color.EtchedBorder→border: 2px groove|ridge color.CompoundBorderwithEmptyBorderinner → outer border + inner's insets as padding. Other inner types WARN.TitledBorder→ inner border (or1px soliddefault) +data-emul-border-titleattribute carrying the title text; pseudo-element CSS rule injected once per UI viaensureTitledBorderStyleInjected(UI).- Any other
Border(including custom user subclasses) → WARN.
clearBorderCss(Element)runs first so the previous border's keys can't linger.border = nullclears without writing — same semantics as Swing'ssetBorder(null). -
borderFromCss
Reconstruct the closest JDKBorderfrom the CSS currently written onelement. Reverse ofapplyBorderCss(Element, Border)— lossy per SD_border_css_lossy: custom Borders, TitledBorder, CompoundBorder with a non-EmptyBorder inner, and icon-backed MatteBorder can't round-trip.Dispatch:
- No border keys, no padding →
null. - Padding only →
EmptyBorder. - Uniform
borderwithsolidstyle →LineBorder(picks upborder-radiusintoroundedCorners). - Uniform
borderwithinset/outset→BevelBorder. - Uniform
borderwithgroove/ridge→EtchedBorder. - Mixed per-side widths/colors →
MatteBorder. - Border + padding →
CompoundBorderof reconstructed outer +EmptyBorderinner.
- No border keys, no padding →
-