public class Border
- Object
- Border
Known subtypesCSSBorder, RoundBorder, RoundRectBorder
Base class that allows us to render a border for a component, a border is drawn before the component and is drawn within the padding region of the component. It is the responsibility of the component not to draw outside of the border line.
This class can be extended to provide additional border types and custom made border types.
A border can optionally paint the background of the component, this depends on the border type and is generally required for rounded borders that “know” the area that should be filled.
Constructors
protected Border() | Prevents usage of new operator, use the factory methods in the class or subclass to create new border types. |
Methods
public static Border getEmpty() | Deprecated Returns an empty border, this is mostly useful for overriding components that have a border by default |
public static Border createEmpty() | Creates an empty border, this is useful where we don’t want a border for a component but want a focus border etc… |
public static Border createImageBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background) | The given top/bottom/left/right images are tiled appropriately across the matching sides of the border and the corners are placed as expected in the four corners. |
public static Border createImageSplicedBorder(Image img, double topInset, double rightInset, double bottomInset, double leftInset) | The given image is spliced into 9 pieces based on the provided top, right, bottom, and left insets, and the resulting sub-images are used to form a 9-piece image border via com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.I... |
public static Border createImageScaledBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background) | The given top/bottom/left/right images are scaled appropriately across the matching sides of the border and the corners are placed as expected in the four corners. |
public static Border createHorizonalImageBorder(Image left, Image right, Image center) | This is an image border that can only grow horizontally |
public static Border createVerticalImageBorder(Image top, Image bottom, Image center) | This is an image border that can only grow vertically |
public static Border createImageBorder(Image top, Image topLeft, Image background) | The given images are tiled appropriately across the matching side of the border, rotated and placed as expected in the four corners. |
public static Border createLineBorder(int thickness) | Creates a line border that uses the color of the component foreground for drawing |
public static Border createLineBorder(float thickness) | Creates a line border that uses the color of the component foreground for drawing |
public static Border createUndelineBorder(int thickness) | Deprecated Creates an underline border that uses the color of the component foreground for drawing |
public static Border createUnderlineBorder(int thickness) | Creates an underline border that uses the color of the component foreground for drawing |
public static Border createUndelineBorder(float thickness) | Deprecated Creates an underline border that uses the color of the component foreground for drawing |
public static Border createUnderlineBorder(float thickness) | Creates an underline border that uses the color of the component foreground for drawing |
public static Border createUnderlineBorder(int thickness, int color) | Creates an underline border that uses the given color |
public static Border createUnderlineBorder(float thickness, int color) | Creates an underline border that uses the given color |
public static Border createDottedBorder(int thickness, int color) | Creates a dotted border with the specified thickness and color |
public static Border createDashedBorder(int thickness, int color) | Creates a dashed border with the specified thickness and color |
public static Border createDoubleBorder(int thickness, int color) | Creates a double border with the specified thickness and color |
public static Border createDottedBorder(int thickness) | Creates a dotted border with the specified thickness and the theme colors |
public static Border createDashedBorder(int thickness) | Creates a dashed border with the specified thickness and the theme colors |
public static Border createDoubleBorder(int thickness) | Creates a double border with the specified thickness and color |
public static Border createOutsetBorder(int thickness) | Creates an outset border with the specified thickness and theme colors |
public static Border createOutsetBorder(int thickness, int color) | Creates an outset border with the specified thickness and color |
public static Border createInsetBorder(int thickness) | Creates an inset border with the specified thickness and theme colors |
public static Border createInsetBorder(int thickness, int color) | Creates an inset border with the specified thickness and color |
public static Border createGrooveBorder(int thickness) | Creates a groove border with the specified thickness and theme colors |
public static Border createGrooveBorder(int thickness, int color) | Creates a groove border with the specified thickness and color |
public static Border createRidgeBorder(int thickness) | Creates a ridge border with the specified thickness and theme colors |
public static Border createRidgeBorder(int thickness, int color) | Creates a ridge border with the specified thickness and color |
public static Border createLineBorder(int thickness, String title) | Creates a line border with the specified title |
public static Border createLineBorder(int thickness, int color, String title) | Creates a line border that uses the given color for the component |
public static Border createLineBorder(int thickness, int color) | Creates a line border that uses the given color for the component |
public static Border createLineBorder(float thickness, int color) | Creates a line border that uses the given color for the component |
public static Border createRoundBorder(int arcWidth, int arcHeight) | Deprecated Creates a rounded corner border that uses the color of the component foreground for drawing. |
public static Border createRoundBorder(int arcWidth, int arcHeight, boolean outline) | Deprecated Creates a rounded corner border that uses the color of the component foreground for drawing. |
public static Border createRoundBorder(int arcWidth, int arcHeight, int color) | Deprecated Creates a rounded border that uses the given color for the component. |
public static Border createRoundBorder(int arcWidth, int arcHeight, int color, boolean outline) | Deprecated Creates a rounded border that uses the given color for the component. |
public static Border createEtchedLowered() | Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color |
public static Border createEtchedLowered(int highlight, int shadow) | Creates a raised etched border with the given colors |
public static Border createEtchedRaised() | Creates a lowered etched border with default colors, highlight is derived from the component and shadow is a plain dark color |
public static Border createEtchedRaised(int highlight, int shadow) | Creates a raised etched border with the given colors |
public static Border createCompoundBorder(Border top, Border bottom, Border left, Border right) | Creates a border that is comprised of multiple border types so one border type can be used on top while another one can be used at the bottom. |
public static Border createBevelLowered() | Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color |
public static Border createBevelLowered(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner) | Creates a raised bevel border with the given colors |
public static Border createBevelRaised() | Creates a lowered bevel border with default colors, highlight is derived from the component and shadow is a plain dark color |
public static Border createBevelRaised(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner) | Creates a raised bevel border with the given colors |
public static Border getDefaultBorder() | Gets the default border to the given value |
public static void setDefaultBorder(Border border) | Sets the default border to the given value |
public Border mirrorBorder() | If a border is a horizontal image border it can be mirrored which is useful for an RTL scenario |
public void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Component trackComponent) | This method is designed mainly for the purpose of creating an arrow that will track a specific component using the image border the tile given would be an arrow like image just like the ones used for the top/bottom/left/right images. |
protected Rectangle getTrackComponent() | The track component is an area to which an arrow based border should point at. |
public void setTrackComponent(Component trackComponent) | In the case of an arrow border the track component lets us track the position to which the border is pointing |
public void setTrackComponent(Rectangle trackComponent) | In the case of an arrow border the track component lets us track the position to which the border is pointing |
public void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Rectangle trackComponent) | This method is designed mainly for the purpose of creating an arrow that will track a specific component using the image border the tile given would be an arrow like image just like the ones used for the top/bottom/left/right images. |
public void clearImageBorderSpecialTile() | Cleans the tile tracking state allowing the garbage collector to pick up the component and the image data |
public void addOuterBorder(Border outer) | Ads a border that wraps this border |
public 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. for the case of an image border the minimum height would be top + bottom and the m… |
public 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. for the case of an image border the minimum height would be top + bottom and the m… |
public boolean isEmptyBorder() | Indicates whether this is an empty border |
public boolean equals(Object obj) | {Indicates whether some other object is “equal to” this one. |
public int hashCode() | Returns a hash code value for the object. |
public boolean isBackgroundPainter() | Returns true if installing this border will override the painting of the component background |
public boolean isRectangleType() | Returns true if this border type is a rectangle border. |
public Border getFocusedInstance() | Deprecated Returns the focused version of the border if one is installed |
public void setFocusedInstance(Border focused) | Deprecated Allows us to define a border that will act as the focused version of this border |
public Border getPressedInstance() | Returns the pressed version of the border if one is set by the user |
public void setPressedInstance(Border pressed) | Allows us to define a border that will act as the pressed version of this border |
public Border createPressedVersion() | When applied to buttons borders produce a version that reverses the effects of the border providing a pressed feel |
public 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. |
public void paint(Graphics g, Component c) | Draws the border for the given component, this method is called before a call to background painting is made. |
public int getThickness() | This method returns how thick is the border in pixels, notice this doesn’t apply to most border types |
public void setThickness(int thickness) | This method returns sets the border thickness in pixels, notice this doesn’t apply to most border types |
public boolean isPaintOuterBorderFirst() | Allows toggling the order in which the outer and inner borders are painted for the Outer border type |
public void setPaintOuterBorderFirst(boolean paintOuterBorderFirst) | Allows toggling the order in which the outer and inner borders are painted for the Outer border type |
public Border[] getCompoundBorders() | This method returns the Compound Borders array. |
public void lock() | This callback indicates that a component pointing at this border is initialized, this method is useful for image borders whose lock methods are implicitly invoked. |
public void unlock() | This callback indicates that a component pointing at this border is now deinitilized This method may be invoked multiple times. |
public Object getProperty(String n) | This method is for internal usage only! |
Inherited methods
Constructor details
Border
protected Border()Method details
getEmpty
public static Border getEmpty()Returns
createEmpty
public static Border createEmpty()Returns
createImageBorder
public static Border createImageBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background)The given top/bottom/left/right images are tiled appropriately across the matching sides of the border and the corners are placed as expected in the four corners. The background image is optional and it will be tiled in the background if necessary.
By default this border does not override background unless a background image is specified
Parameters
topImage- the image of the top line
bottomImage- the image of the bottom line
leftImage- the image of the left line
rightImage- the image of the right line
topLeftImage- the image of the top left corner
topRightImage- the image of the top right corner
bottomLeftImage- the image of the bottom left corner
bottomRightImage- the image of the bottom right corner
backgroundImage- the image of the background (optional)
Returns
createImageSplicedBorder
public static Border createImageSplicedBorder(Image img, double topInset, double rightInset, double bottomInset, double leftInset)The given image is spliced into 9 pieces based on the provided top, right, bottom, and left insets, and the resulting
sub-images are used to form a 9-piece image border via com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image)
Insets are all given in a (u,v) coordinate space where (0,0) is the top-left corner of the image, and (1.0, 1.0) is the bottom-right corner of the image.
Parameters
imgImage- The image to be used as a background image and spliced.
topInsetdouble- Not documented.
rightInsetdouble- Not documented.
bottomInsetdouble- Not documented.
leftInsetdouble- Not documented.
Returns
createImageScaledBorder
public static Border createImageScaledBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background)The given top/bottom/left/right images are scaled appropriately across the matching sides of the border and the corners are placed as expected in the four corners. The background image is optional and it will be tiled in the background if necessary.
By default this border does not override background unless a background image is specified
Parameters
topImage- the image of the top line
bottomImage- the image of the bottom line
leftImage- the image of the left line
rightImage- the image of the right line
topLeftImage- the image of the top left corner
topRightImage- the image of the top right corner
bottomLeftImage- the image of the bottom left corner
bottomRightImage- the image of the bottom right corner
backgroundImage- the image of the background (optional)
Returns
createHorizonalImageBorder
public static Border createHorizonalImageBorder(Image left, Image right, Image center)Parameters
leftImage- the image of the left side
rightImage- the image of the right side
centerImage- the image of the center
Returns
createVerticalImageBorder
public static Border createVerticalImageBorder(Image top, Image bottom, Image center)Parameters
topImage- the image of the top
bottomImage- the image of the bottom
centerImage- the image of the center
Returns
createImageBorder
public static Border createImageBorder(Image top, Image topLeft, Image background)The given images are tiled appropriately across the matching side of the border, rotated and placed as expected in the four corners. The background image is optional and it will be tiled in the background if necessary.
By default this border does not override background unless a background image is specified.
Notice that this version of the method is potentially much more efficient since images are rotated internally and this might save quite a bit of memory!
The top and topLeft images must be square! The width and height of these images must be equal otherwise rotation won’t work as you expect.
Parameters
topImage- the image of the top line
topLeftImage- the image of the top left corner
backgroundImage- the image of the background (optional)
Returns
createLineBorder
public static Border createLineBorder(int thickness)Parameters
thicknessint- thickness of the border in pixels
Returns
createLineBorder
public static Border createLineBorder(float thickness)Parameters
thicknessfloat- thickness of the border in millimeters
Returns
createUndelineBorder
public static Border createUndelineBorder(int thickness)thickness)Parameters
thicknessint- thickness of the border in pixels
Returns
createUnderlineBorder
public static Border createUnderlineBorder(int thickness)Parameters
thicknessint- thickness of the border in pixels
Returns
createUndelineBorder
public static Border createUndelineBorder(float thickness)thickness)Parameters
thicknessfloat- thickness of the border in millimeters
Returns
createUnderlineBorder
public static Border createUnderlineBorder(float thickness)Parameters
thicknessfloat- thickness of the border in millimeters
Returns
createUnderlineBorder
public static Border createUnderlineBorder(int thickness, int color)Parameters
thicknessint- thickness of the border in pixels
colorint- the color
Returns
createUnderlineBorder
public static Border createUnderlineBorder(float thickness, int color)Parameters
thicknessfloat- thickness of the border in millimeters
colorint- the color
Returns
createDottedBorder
public static Border createDottedBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createDashedBorder
public static Border createDashedBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createDoubleBorder
public static Border createDoubleBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createDottedBorder
public static Border createDottedBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createDashedBorder
public static Border createDashedBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createDoubleBorder
public static Border createDoubleBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createOutsetBorder
public static Border createOutsetBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createOutsetBorder
public static Border createOutsetBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createInsetBorder
public static Border createInsetBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createInsetBorder
public static Border createInsetBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createGrooveBorder
public static Border createGrooveBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createGrooveBorder
public static Border createGrooveBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createRidgeBorder
public static Border createRidgeBorder(int thickness)Parameters
thicknessint- The border thickness in pixels
Returns
createRidgeBorder
public static Border createRidgeBorder(int thickness, int color)Parameters
thicknessint- The border thickness in pixels
colorint- The border color
Returns
createLineBorder
public static Border createLineBorder(int thickness, String title)Parameters
thicknessint- thickness of the border in pixels
titleString- The borders title
Returns
createLineBorder
public static Border createLineBorder(int thickness, int color, String title)Parameters
thicknessint- thickness of the border in pixels
colorint- the color for the border
titleString- The borders title
Returns
createLineBorder
public static Border createLineBorder(int thickness, int color)Parameters
thicknessint- thickness of the border in pixels
colorint- the color for the border
Returns
createLineBorder
public static Border createLineBorder(float thickness, int color)Parameters
thicknessfloat- thickness of the border in millimeters
colorint- the color for the border
Returns
createRoundBorder
public static Border createRoundBorder(int arcWidth, int arcHeight)Creates a rounded corner border that uses the color of the component foreground for drawing. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a painter.
Parameters
arcWidthint- the horizontal diameter of the arc at the four corners.
arcHeightint- the vertical diameter of the arc at the four corners.
Returns
createRoundBorder
public static Border createRoundBorder(int arcWidth, int arcHeight, boolean outline)Creates a rounded corner border that uses the color of the component foreground for drawing. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a painter.
Parameters
arcWidthint- the horizontal diameter of the arc at the four corners.
arcHeightint- the vertical diameter of the arc at the four corners.
outlineboolean- whether the round rect border outline should be drawn
Returns
createRoundBorder
public static Border createRoundBorder(int arcWidth, int arcHeight, int color)Creates a rounded border that uses the given color for the component. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a painter.
Parameters
arcWidthint- the horizontal diameter of the arc at the four corners.
arcHeightint- the vertical diameter of the arc at the four corners.
colorint- the color for the border
Returns
createRoundBorder
public static Border createRoundBorder(int arcWidth, int arcHeight, int color, boolean outline)Creates a rounded border that uses the given color for the component. Due to technical issues (lack of shaped clipping) performance and memory overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a painter.
Parameters
arcWidthint- the horizontal diameter of the arc at the four corners.
arcHeightint- the vertical diameter of the arc at the four corners.
colorint- the color for the border
outlineboolean- whether the round rect border outline should be drawn
Returns
createEtchedLowered
public static Border createEtchedLowered()Returns
createEtchedLowered
public static Border createEtchedLowered(int highlight, int shadow)Parameters
highlightint- color RGB value
shadowint- color RGB value
Returns
createEtchedRaised
public static Border createEtchedRaised()Returns
createEtchedRaised
public static Border createEtchedRaised(int highlight, int shadow)Parameters
highlightint- color RGB value
shadowint- color RGB value
Returns
createCompoundBorder
public static Border createCompoundBorder(Border top, Border bottom, Border left, Border right)Parameters
topBorder- the top border
bottomBorder- the bottom border
leftBorder- the left border
rightBorder- the right border
Returns
createBevelLowered
public static Border createBevelLowered()Returns
createBevelLowered
public static Border createBevelLowered(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner)Parameters
highlightOuterint- RGB of the outer edge of the highlight area
highlightInnerint- RGB of the inner edge of the highlight area
shadowOuterint- RGB of the outer edge of the shadow area
shadowInnerint- RGB of the inner edge of the shadow area
Returns
createBevelRaised
public static Border createBevelRaised()Returns
createBevelRaised
public static Border createBevelRaised(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner)Parameters
highlightOuterint- RGB of the outer edge of the highlight area
highlightInnerint- RGB of the inner edge of the highlight area
shadowOuterint- RGB of the outer edge of the shadow area
shadowInnerint- RGB of the inner edge of the shadow area
Returns
getDefaultBorder
public static Border getDefaultBorder()Returns
setDefaultBorder
public static void setDefaultBorder(Border border)Parameters
borderBorder- new border value
mirrorBorder
public Border mirrorBorder()Returns
setImageBorderSpecialTile
public void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Component trackComponent)Parameters
tileTopImage- an image that will replace one of the tiles on the top if the track component is there
tileBottomImage- an image that will replace one of the tiles on the bottom if the track component is there
tileLeftImage- an image that will replace one of the tiles on the left if the track component is there
tileRightImage- an image that will replace one of the tiles on the right if the track component is there
trackComponentComponent- the component that will be tracked for the positioning of the tile
getTrackComponent
protected Rectangle getTrackComponent()Returns
setTrackComponent
public void setTrackComponent(Component trackComponent)Parameters
trackComponentComponent- the track component
setTrackComponent
public void setTrackComponent(Rectangle trackComponent)Parameters
trackComponentRectangle- the track component
setImageBorderSpecialTile
public void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Rectangle trackComponent)Parameters
tileTopImage- an image that will replace one of the tiles on the top if the track component is there
tileBottomImage- an image that will replace one of the tiles on the bottom if the track component is there
tileLeftImage- an image that will replace one of the tiles on the left if the track component is there
tileRightImage- an image that will replace one of the tiles on the right if the track component is there
trackComponentRectangle- the component that will be tracked for the positioning of the tile
clearImageBorderSpecialTile
public void clearImageBorderSpecialTile()addOuterBorder
public void addOuterBorder(Border outer)Parameters
outerBorder- The outer border
getMinimumHeight
public int getMinimumHeight()Returns
getMinimumWidth
public int getMinimumWidth()Returns
isEmptyBorder
public boolean isEmptyBorder()Returns
equals
public boolean equals(Object obj)hashCode
public int hashCode()isBackgroundPainter
public boolean isBackgroundPainter()Returns
isRectangleType
public boolean isRectangleType()Returns
getFocusedInstance
public Border getFocusedInstance()Returns
setFocusedInstance
public void setFocusedInstance(Border focused)Parameters
focusedBorder- a border that will be returned by the focused version method
getPressedInstance
public Border getPressedInstance()Returns
setPressedInstance
public void setPressedInstance(Border pressed)Parameters
pressedBorder- a border that will be returned by the pressed version method
createPressedVersion
public Border createPressedVersion()Returns
paintBorderBackground
public void paintBorderBackground(Graphics g, Component c)Parameters
gGraphics- graphics context to draw onto
cComponent- component whose border should be drawn
paint
public void paint(Graphics g, Component c)Parameters
gGraphics- graphics context to draw onto
cComponent- component whose border should be drawn
getThickness
public int getThickness()Returns
setThickness
public void setThickness(int thickness)Parameters
thicknessint- the Border thickness
isPaintOuterBorderFirst
public boolean isPaintOuterBorderFirst()Returns
setPaintOuterBorderFirst
public void setPaintOuterBorderFirst(boolean paintOuterBorderFirst)Parameters
paintOuterBorderFirstboolean- whether the outside border should be painter first
getCompoundBorders
public Border[] getCompoundBorders()Border top = borders[Component.TOP];
Border bottom = borders[Component.BOTTOM];
Border left = borders[Component.LEFT];
Border right = borders[Component.RIGHT];Returns
lock
public void lock()unlock
public void unlock()getProperty
public Object getProperty(String n)