background

fun SwingModifier.background(brush: Brush, shape: Shape = RectangleShape, @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1.0f): SwingModifier

Fills shape's outline with brush under the component's content.

An opaque component, such as a custom JPanel-based Decoratable under most looks and feels, fills its background over the brush, so set opaque(false) in the style of such a component for the fill to show. A Row, Column and Box are transparent unless set opaque. An outline other than RectangleShape is filled with an antialiased edge, as AndroidX's background fills it.

Return

this chain with the background declared on it.

Parameters

brush

the fill, resolved against the decorated box.

shape

the outline to fill; the whole decorated box by default.

alpha

the fraction of the brush's opacity to fill with; 1 by default. A value above 1 fills as 1, and one below 0 or NaN as 0.


Fills shape's outline with color under the component's content; the solid-color overload of background.

shape has no default here, so a call naming only a color is always the style setter background, which writes the Swing property a look and feel honors.

Return

this chain with the background declared on it.

Parameters

color

the fill.

shape

the outline to fill; RectangleShape for the whole decorated box.