Class Icons
java.lang.Object
com.vaadin.swingbridge.surrogates.util.Icons
Icon → Vaadin bridge (icon-rendering Path 1). When the user's
Icon
is an ImageIcon, extract its raster, encode as PNG, and wrap it via
Vaadin's byte-array Image ctor so the Swing-side icon reaches the
Vaadin DOM as a real <img>. Other Icon impls (custom Path 3
paint callbacks, Vaadin-/Lumo-glyph keys for Path 2) WARN-and-drop — Path 1
is the in-scope slice.
Shared across both modules in the SD_shelper_statics-allowed direction —
:emulators (EHelper, JComboBox) calls
imageIconToVaadinImage(ImageIcon) for its own icon rendering, surrogates
call toVaadinIconComponent(Object, Icon).
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.vaadin.flow.component.html.ImageEncode anImageIcon's raster as PNG and wrap it in a VaadinImagevia thebyte[]ctor (auto-derives mime from the.pngsuffix and installs an inline-dispositionDownloadHandlerunder the hood).static com.vaadin.flow.component.ComponenttoVaadinIconComponent(Object self, Icon icon)
-
Method Details
-
toVaadinIconComponent
Convert a SwingIconto a VaadinComponentsuitable forButton.setIcon.null→null(peers interpret as "remove icon").ImageIcon→ImagefromImage(byte[], String)— wraps the icon's raster PNG-encoded with an inline-disposition download handler.- Anything else →
SHelper.onUnimplemented(Object, String, Object...)+null: Path 2 (UIManagerkey →VaadinIcon) and Path 3 (offscreenBufferedImagepaint of arbitraryIconimpls) are deferred.
The
selfargument is the receiver instance for the WARN's class name; pass the surrogate / mixin owner. Caller is responsible for forwarding the result to the peer's VaadinsetIcon. -
imageIconToVaadinImage
Encode anImageIcon's raster as PNG and wrap it in a VaadinImagevia thebyte[]ctor (auto-derives mime from the.pngsuffix and installs an inline-dispositionDownloadHandlerunder the hood). Returnsnullwhen the icon is null or has no positive dimensions (e.g. a default- constructedImageIconthat never loaded a source) — caller treats that as "no icon to install."If the icon carries a description, it overrides the default filename-as-alt the ctor sets.
-