# Class RoundBorder

java.lang.Object
com.codename1.ui.plaf.Border
com.codename1.ui.plaf.RoundBorder

public final class RoundBorder extends Border

A border that can either be a circle or a circular rectangle which is a rectangle whose sides are circles. This border can optionally have a drop shadow associated with it.

IMPORTANT: `RoundRectBorder` instances can't be reused you would need to create a separate instance for each style object! See this issue for further details.

    Form hi = new Form("Round", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER));

    Button ok = new Button("OK");
    Button cancel = new Button("Cancel");

    Label loginLabel = new Label("Login", "Container");
    loginLabel.getAllStyles().setAlignment(Component.CENTER);

    Label passwordLabel = new Label("Password", "Container");
    passwordLabel.getAllStyles().setAlignment(Component.CENTER);

    TextField login = new TextField("", "Login", 20, TextArea.ANY);
    TextField password = new TextField("", "Password", 20, TextArea.PASSWORD);
    Style loginStyle = login.getAllStyles();
    Stroke borderStroke = new Stroke(2, Stroke.CAP_SQUARE, Stroke.JOIN_MITER, 1);
    loginStyle.setBorder(RoundBorder.create().
            rectangle(true).
            color(0xffffff).
            strokeColor(0).
            strokeOpacity(120).
            stroke(borderStroke));
    loginStyle.setMarginUnit(Style.UNIT_TYPE_DIPS);
    loginStyle.setMargin(Component.BOTTOM, 3);
    Style passwordStyle = password.getAllStyles();
    passwordStyle.setBorder(RoundBorder.create().
            rectangle(true).
            color(0xffffff).
            strokeColor(0).
            strokeOpacity(120).
            stroke(borderStroke));

    Container box = BoxLayout.encloseY(
            loginLabel,
            login,
            passwordLabel,
            password,
                GridLayout.encloseIn(2, cancel, ok));

    Button closeButton = new Button();
    Style closeStyle = closeButton.getAllStyles();
    closeStyle.setFgColor(0xffffff);
    closeStyle.setBgTransparency(0);
    closeStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
    closeStyle.setPadding(3, 3, 3, 3);
    closeStyle.setBorder(RoundBorder.create().shadowOpacity(100));
    FontImage.setMaterialIcon(closeButton, FontImage.MATERIAL_CLOSE);

    Container layers = LayeredLayout.encloseIn(box, FlowLayout.encloseRight(closeButton));
    Style boxStyle = box.getUnselectedStyle();
    boxStyle.setBgTransparency(255);
    boxStyle.setBgColor(0xeeeeee);
    boxStyle.setMarginUnit(Style.UNIT_TYPE_DIPS);
    boxStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
    boxStyle.setMargin(4, 3, 3, 3);
    boxStyle.setPadding(2, 2, 2, 2);

    hi.add(BorderLayout.CENTER, layers);

    hi.show();

- ## Method Summary

  Modifier and Type
  Method
  Description
  `RoundBorder`
  `color(int color)`
  Sets the background color of the circle/rectangle
  `static RoundBorder`
  `create()`
  Creates a flat round border with no stroke and no shadow and the default color, this call can be chained with the other calls to mutate the color/opacity etc.
  `boolean`
  `equals(Object obj)`
  {{}
  `int`
  `getColor()`
  The color of the border background
  `int`
  `getMinimumHeight()`
  Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g.
  `int`
  `getMinimumWidth()`
  Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g.
  `int`
  `getOpacity()`
  The opacity (transparency) of the border background
  `float`
  `getShadowBlur()`
  The Gaussian blur size
  `int`
  `getShadowOpacity()`
  The opacity of the shadow between 0 and 255
  `int`
  `getShadowSpread()`
  The spread of the shadow in pixels of millimeters
  `float`
  `getShadowX()`
  X axis bias of the shadow between 0 and 1 where 0 is to the top and 1 is to the bottom, defaults to 0.5
  `float`
  `getShadowY()`
  Y axis bias of the shadow between 0 and 1 where 0 is to the left and 1 is to the right, defaults to 0.5
  `int`
  `getStrokeColor()`
  The color of the edge of the border if applicable
  `int`
  `getStrokeOpacity()`
  The opacity of the edge of the border if applicable
  `float`
  `getStrokeThickness()`
  The thickness of the edge of the border if applicable, 0 if no stroke is needed
  `boolean`
  `getUIID()`
  True is we use the background of the component setting to draw
  `int`
  `hashCode()`
  `boolean`
  `isBackgroundPainter()`
  Returns true if installing this border will override the painting of the component background
  `boolean`
  `isOnlyLeftRounded()`
  Checks if only left side is rounded.
  `boolean`
  `isOnlyRightRounded()`
  Checks if only right side is rounded.
  `boolean`
  `isRectangle()`
  True if this border grows into a rectangle horizontally or keeps growing as a circle
  `boolean`
  `isShadowMM()`
  True if the shadow spread is in millimeters
  `boolean`
  `isStrokeMM()`
  True if the thickness of the stroke is in millimeters
  `RoundBorder`
  `onlyLeftRounded(boolean onlyLeftRounded)`
  Forces a special case of the rectangle mode that renders the right side as square.
  `RoundBorder`
  `onlyRightRounded(boolean onlyRightRounded)`
  Forces a special case of the rectangle mode that renders the left side as square.
  `RoundBorder`
  `opacity(int opacity)`
  Sets the background opacity of the circle/rectangle
  `void`
  `paintBorderBackground(Graphics g, Component c)`
  Has effect when the border demands responsibility for background painting normally the painter will perform this work but in this case the border might do it instead.
  `RoundBorder`
  `rectangle(boolean rectangle)`
  When set to true this border grows into a rectangle when the space isn't perfectly circular
  `RoundBorder`
  `shadowBlur(float shadowBlur)`
  The blur on the shadow this is the standard Gaussian blur radius
  `RoundBorder`
  `shadowOpacity(int shadowOpacity)`
  Sets the opacity of the shadow from 0 - 255 where 0 means no shadow and 255 means opaque black shadow
  `RoundBorder`
  `shadowSpread(int shadowSpread)`
  Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle
  `RoundBorder`
  `shadowSpread(int shadowSpread, boolean mm)`
  Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle
  `RoundBorder`
  `shadowX(float shadowX)`
  The position of the shadow on the X axis where 0.5f means the center and higher values draw it to the right side
  `RoundBorder`
  `shadowY(float shadowY)`
  The position of the shadow on the Y axis where 0.5f means the center and higher values draw it to the bottom
  `RoundBorder`
  `stroke(float stroke, boolean mm)`
  Sets the stroke of the circle/rectangle
  `RoundBorder`
  `stroke(Stroke stroke)`
  Sets the stroke of the circle/rectangle
  `RoundBorder`
  `strokeAngle(int strokeAngle)`
  Sets the stroke angle of the circle, this only applies to circular versions
  `RoundBorder`
  `strokeColor(int strokeColor)`
  Sets the stroke color of the circle/rectangle
  `RoundBorder`
  `strokeOpacity(int strokeOpacity)`
  Sets the opacity of the stroke line around the circle/rectangle
  `RoundBorder`
  `uiid(boolean uiid)`
  Uses the style of the components UIID to draw the background of the border, this effectively overrides all other style settings but allows the full power of UIID drawing including gradients, background images etc.

  ### Methods inherited from class Border

  `addOuterBorder, clearImageBorderSpecialTile, createBevelLowered, createBevelLowered, createBevelRaised, createBevelRaised, createCompoundBorder, createDashedBorder, createDashedBorder, createDottedBorder, createDottedBorder, createDoubleBorder, createDoubleBorder, createEmpty, createEtchedLowered, createEtchedLowered, createEtchedRaised, createEtchedRaised, createGrooveBorder, createGrooveBorder, createHorizonalImageBorder, createImageBorder, createImageBorder, createImageScaledBorder, createImageSplicedBorder, createInsetBorder, createInsetBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createOutsetBorder, createOutsetBorder, createPressedVersion, createRidgeBorder, createRidgeBorder, createRoundBorder, createRoundBorder, createRoundBorder, createRoundBorder, createUndelineBorder, createUndelineBorder, createUnderlineBorder, createUnderlineBorder, createUnderlineBorder, createUnderlineBorder, createVerticalImageBorder, getCompoundBorders, getDefaultBorder, getEmpty, getFocusedInstance, getPressedInstance, getProperty, getThickness, getTrackComponent, isEmptyBorder, isPaintOuterBorderFirst, isRectangleType, lock, mirrorBorder, paint, setDefaultBorder, setFocusedInstance, setImageBorderSpecialTile, setImageBorderSpecialTile, setPaintOuterBorderFirst, setPressedInstance, setThickness, setTrackComponent, setTrackComponent, unlock`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### create

    public static RoundBorder create()

    Creates a flat round border with no stroke and no shadow and the default color, this call can be chained with the other calls to mutate the color/opacity etc.

    ###### Returns

    a border instance

  - ### uiid

    public RoundBorder uiid(boolean uiid)

    Uses the style of the components UIID to draw the background of the border, this effectively overrides all other style settings but allows the full power of UIID drawing including gradients, background images etc.

    **Notice: **this flag will only work when shaped clipping is supported. That feature isn't available in all platforms...

    ###### Parameters

    - `uiid`: true to use the background of the component setting

    ###### Returns

    border instance so these calls can be chained

  - ### getUIID

    public boolean getUIID()

    True is we use the background of the component setting to draw

    ###### Returns

    true if we draw based on the component UIID

  - ### color

    public RoundBorder color(int color)

    Sets the background color of the circle/rectangle

    ###### Parameters

    - `color`: the color

    ###### Returns

    border instance so these calls can be chained

  - ### opacity

    public RoundBorder opacity(int opacity)

    Sets the background opacity of the circle/rectangle

    ###### Parameters

    - `opacity`: the background opacity from 0-255 where 255 is completely opaque

    ###### Returns

    border instance so these calls can be chained

  - ### strokeOpacity

    public RoundBorder strokeOpacity(int strokeOpacity)

    Sets the opacity of the stroke line around the circle/rectangle

    ###### Parameters

    - `strokeOpacity`: the opacity from 0-255 where 255 is completely opaque

    ###### Returns

    border instance so these calls can be chained

  - ### strokeColor

    public RoundBorder strokeColor(int strokeColor)

    Sets the stroke color of the circle/rectangle

    ###### Parameters

    - `strokeColor`: the color

    ###### Returns

    border instance so these calls can be chained

  - ### stroke

    public RoundBorder stroke(Stroke stroke)

    Sets the stroke of the circle/rectangle

    ###### Parameters

    - `stroke`: the stroke object

    ###### Returns

    border instance so these calls can be chained

  - ### stroke

    public RoundBorder stroke(float stroke, boolean mm)

    Sets the stroke of the circle/rectangle

    ###### Parameters

    - `stroke`: the thickness of the stroke object

    - `mm`: set to true to indicate the value is in millimeters, false indicates pixels

    ###### Returns

    border instance so these calls can be chained

  - ### strokeAngle

    public RoundBorder strokeAngle(int strokeAngle)

    Sets the stroke angle of the circle, this only applies to circular versions

    ###### Parameters

    - `strokeAngle`: the stroke angle in degrees

    ###### Returns

    border instance so these calls can be chained

  - ### shadowSpread

    public RoundBorder shadowSpread(int shadowSpread, boolean mm)

    Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle

    ###### Parameters

    - `shadowSpread`: the amount in pixels representing the size of the shadow

    - `mm`: set to true to indicate the value is in millimeters, false indicates pixels

    ###### Returns

    border instance so these calls can be chained

  - ### shadowSpread

    public RoundBorder shadowSpread(int shadowSpread)

    Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle

    ###### Parameters

    - `shadowSpread`: the amount in pixels representing the size of the shadow

    ###### Returns

    border instance so these calls can be chained

  - ### shadowOpacity

    public RoundBorder shadowOpacity(int shadowOpacity)

    Sets the opacity of the shadow from 0 - 255 where 0 means no shadow and 255 means opaque black shadow

    ###### Parameters

    - `shadowOpacity`: the opacity of the shadow

    ###### Returns

    border instance so these calls can be chained

  - ### shadowX

    public RoundBorder shadowX(float shadowX)

    The position of the shadow on the X axis where 0.5f means the center and higher values draw it to the right side

    ###### Parameters

    - `shadowX`: the position of the shadow between 0 - 1 where 0 equals left and 1 equals right

    ###### Returns

    border instance so these calls can be chained

  - ### shadowY

    public RoundBorder shadowY(float shadowY)

    The position of the shadow on the Y axis where 0.5f means the center and higher values draw it to the bottom

    ###### Parameters

    - `shadowY`: the position of the shadow between 0 - 1 where 0 equals top and 1 equals bottom

    ###### Returns

    border instance so these calls can be chained

  - ### shadowBlur

    public RoundBorder shadowBlur(float shadowBlur)

    The blur on the shadow this is the standard Gaussian blur radius

    ###### Parameters

    - `shadowBlur`: The blur on the shadow this is the standard Gaussian blur radius

    ###### Returns

    border instance so these calls can be chained

  - ### rectangle

    public RoundBorder rectangle(boolean rectangle)

    When set to true this border grows into a rectangle when the space isn't perfectly circular

    ###### Parameters

    - `rectangle`: When set to true this border grows into a rectangle when the space isn't perfectly circular

    ###### Returns

    border instance so these calls can be chained

  - ### onlyLeftRounded

    public RoundBorder onlyLeftRounded(boolean onlyLeftRounded)

    Forces a special case of the rectangle mode that renders the right side as square. This is ignored when the rectangle mode is false

    ###### Parameters

    - `onlyLeftRounded`: the new state of this mode

    ###### Returns

    border instance so these calls can be chained

  - ### isOnlyLeftRounded

    public boolean isOnlyLeftRounded()

    Checks if only left side is rounded.

    ###### Returns

    True if only left side is rounded.

    ###### Since

    7.0

  - ### onlyRightRounded

    public RoundBorder onlyRightRounded(boolean onlyRightRounded)

    Forces a special case of the rectangle mode that renders the left side as square. This is ignored when the rectangle mode is false

    ###### Parameters

    - `onlyRightRounded`: the new state of this mode

    ###### Returns

    border instance so these calls can be chained

  - ### isOnlyRightRounded

    public boolean isOnlyRightRounded()

    Checks if only right side is rounded.

    ###### Returns

    True if only right side is rounded.

    ###### Since

    7.0

  - ### paintBorderBackground

    public void paintBorderBackground(Graphics g, Component c)
    Description copied from class: `Border`

    Has effect when the border demands responsibility for background painting normally the painter will perform this work but in this case the border might do it instead.

    ###### Parameters

    - `g`: graphics context to draw onto

    - `c`: component whose border should be drawn

    Overrides:
      `paintBorderBackground` in class `Border`

  - ### getMinimumHeight

    public int getMinimumHeight()
    Description copied from class: `Border`

    Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g. for the case of an image border the minimum height would be top + bottom and the minimum width would be left+right

    ###### Returns

    0 if not applicable or a dimension if it is.

    Overrides:
      `getMinimumHeight` in class `Border`

  - ### getMinimumWidth

    public int getMinimumWidth()
    Description copied from class: `Border`

    Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g. for the case of an image border the minimum height would be top + bottom and the minimum width would be left+right

    ###### Returns

    0 if not applicable or a dimension if it is.

    Overrides:
      `getMinimumWidth` in class `Border`

  - ### isBackgroundPainter

    public boolean isBackgroundPainter()
    Description copied from class: `Border`

    Returns true if installing this border will override the painting of the component background

    ###### Returns

    true if this border replaces the painter

    Overrides:
      `isBackgroundPainter` in class `Border`

  - ### getColor

    public int getColor()

    The color of the border background

    ###### Returns

    the color

  - ### getOpacity

    public int getOpacity()

    The opacity (transparency) of the border background

    ###### Returns

    the opacity

  - ### getStrokeColor

    public int getStrokeColor()

    The color of the edge of the border if applicable

    ###### Returns

    the strokeColor

  - ### getStrokeOpacity

    public int getStrokeOpacity()

    The opacity of the edge of the border if applicable

    ###### Returns

    the strokeOpacity

  - ### getStrokeThickness

    public float getStrokeThickness()

    The thickness of the edge of the border if applicable, 0 if no stroke is needed

    ###### Returns

    the strokeThickness

  - ### isStrokeMM

    public boolean isStrokeMM()

    True if the thickness of the stroke is in millimeters

    ###### Returns

    the strokeMM

  - ### getShadowSpread

    public int getShadowSpread()

    The spread of the shadow in pixels of millimeters

    ###### Returns

    the shadowSpread

  - ### getShadowOpacity

    public int getShadowOpacity()

    The opacity of the shadow between 0 and 255

    ###### Returns

    the shadowOpacity

  - ### getShadowX

    public float getShadowX()

    X axis bias of the shadow between 0 and 1 where 0 is to the top and 1 is to the bottom, defaults to 0.5

    ###### Returns

    the shadowX

  - ### getShadowY

    public float getShadowY()

    Y axis bias of the shadow between 0 and 1 where 0 is to the left and 1 is to the right, defaults to 0.5

    ###### Returns

    the shadowY

  - ### getShadowBlur

    public float getShadowBlur()

    The Gaussian blur size

    ###### Returns

    the shadowBlur

  - ### isShadowMM

    public boolean isShadowMM()

    True if the shadow spread is in millimeters

    ###### Returns

    the shadowMM

  - ### isRectangle

    public boolean isRectangle()

    True if this border grows into a rectangle horizontally or keeps growing as a circle

    ###### Returns

    the rectangle

  - ### equals

    public boolean equals(Object obj)
    Description copied from class: `Border`
    {}
    Overrides:
      `equals` in class `Border`

  - ### hashCode

    public int hashCode()
    Description copied from class: `Border`
    Overrides:
      `hashCode` in class `Border`