Class Style

java.lang.Object
com.codename1.ui.plaf.Style

public class Style extends Object

Represents the look of a given component: colors, fonts, transparency, margin and padding & images.

Each Component contains a Style Object and allows Style modification in Runtime by Using cmp.getStyle() The style is also used in Themeing, when a Theme is Changed the Styles Objects are been updated automatically.

When changing a theme the elements changed manually in a style will not be updated by the theme change by default. There are two ways to change that behavior:

  • Use the set method that accepts a second boolean argument and set it to true.

  • Create a new style object and pass all the options in the constructor (without invoking setters manually).

The Margin and Padding is inspired by W3 Box Model

      **************************
      *         Margin         *
      *  ********************  *
      *  *      Padding     *  *
      *  *    ***********   *  *
      *  *    * Content *   *  *
      *  *    ***********   *  *
      *  *      Padding     *  *
      *  ********************  *
      *         Margin         *
      **************************

Change Events

Styles fire a change event for each style change that occurs. Component listens to all changes events of its styles, and adjusts some of its properties accordingly. Currently (as of 6.0) each style change will trigger a Container#revalidate() call on the Style's Component's parent container, which is expensive. You can disable this Container#revalidate() call by calling CN.setProperty("Component.revalidateOnStyleChange", "false"). This will likely be the default behavior in a future version, so we recommend you disable this explicitly for both performance reasons, and to avoid regressions when the default is changed.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Alignment attribute for the style event
    static final String
    Background attribute name for the theme hashtable
    static final String
    Background attribute name for the theme hashtable
    static final byte
    Indicates the background for the style would use a linear gradient
    static final byte
    Indicates the background for the style would use a linear gradient
    static final byte
    Indicates the background for the style would use a radial gradient
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use an unscaled image with an alignment
    static final byte
    Indicates the background for the style would use a scaled image
    static final byte
    Indicates the background for the style would use a scaled image that fills all available space while maintaining aspect ratio
    static final byte
    Indicates the background for the style would use a scaled image that fits to available space while maintaining aspect ratio
    static final byte
    Indicates the background for the style would use a tiled image on both axis
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a vertical tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a horizontal tiled image
    static final byte
    Indicates the background for the style would use a scaled image
    static final String
    Background attribute name for the theme hashtable
    static final String
    Background color attribute name for the theme hashtable
    static final String
    Background image attribute name for the theme hashtable
    static final String
    Border attribute name for the theme hashtable
    static final String
    Elevation attribute name for the theme hashtable.
    static final String
    Foreground alpha attribute name for the theme hashtable
    static final String
    Foreground color attribute name for the theme hashtable
    static final String
    Font attribute name for the theme hashtable
    static final String
    Icon gap attribute name for the theme hashtable.
    static final String
    Icon gap unit attribute.
    static final String
    Margin attribute name for the theme hashtable
    static final String
    The units of the margin
    static final String
    Opacity attribute name for the theme hashtable
    static final String
    Padding attribute name for the theme hashtable
    static final String
    The units of the padding
    static final String
    Painter attribute name for the style event
    static final String
    Surface attribute name for the theme hashtable.
    static final String
    Text decoration attribute for the style event
    static final byte
    3D text effect using a font shadow
    static final byte
    3D sunken text effect using a light font shadow
    static final byte
    3D text effect using a font shadow
    static final byte
    Indicates no text decoration
    static final byte
    Indicates overline
    static final byte
    Indicates a strike-through line (usually used to denote deleted text)
    static final byte
    Indicates underline
    static final String
    Transparency attribute name for the theme hashtable
    static final byte
    Indicates the unit type for padding/margin in device independent pixels.
    static final byte
    Indicates the unit type for padding/margin, the default is in device specific pixels
    static final byte
    Indicates the unit type for padding/margin relative to the font size of the default font.
    static final byte
    Indicates the unit type for padding/margin in percentage of the size of the screen
    static final byte
    Indicates the unit type for padding/margin as a percentage of the screen height.
    static final byte
    Indicates the unit type for padding/margin as a percentage the maximum of screen width and height.
    static final byte
    Indicates the unit type for padding/margin as a percentage the minimum of screen width and height.
    static final byte
    Indicates the unit type for padding/margin as a percentage of the screen width.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Each component when it draw itself uses this Object to determine in what colors it should use.
    Style(int fgColor, int bgColor, Font f, byte transparency)
    Creates a new style with the given attributes
    Style(int fgColor, int bgColor, Font f, byte transparency, Image im, byte backgroundType)
    Creates a new style with the given attributes
    Style(Style style)
    Creates a full copy of the given style.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a Style Listener to the Style Object.
    void
    cacheMargins(boolean override)
    Store current margin values into a cache that could be restored with restoreCachedMargins()
    static Style
    Creates a "proxy" style whose setter methods map to the methods in the given styles passed and whose getter methods are meaningless
    boolean
     
    void
    Flush the margins cache if one exists
    int
    Returns the alignment of the Label
    int
    End color for the radial/linear gradient
    float
    Background radial gradient relative size
    float
    Background radial gradient relative center position X
    float
    Background radial gradient relative center position Y
    int
    Start color for the radial/linear gradient
    byte
    The type of the background defaults to BACKGROUND_IMAGE_SCALED
    int
    Background color for the component
    Background image for the component
    Return the background painter for this style, normally this would be the internal image/color painter but can be user defined
    byte
    Returns the transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.
    Returns the border for the style
    int
    Gets the elevation value of this style.
    int
    Foreground alpha for the component
    int
    Foreground color for the component
    Font for the component
    int
    The equivalent of getMarginLeft + getMarginRight
    int
    The equivalent of getPaddingLeft + getPaddingRight
    int
    Returns the icon gap in pixels.
    int
    Returns the icon gap unit.
    int
    getMargin(boolean rtl, int orientation)
    Returns the Margin
    int
    getMargin(int orientation)
    Returns the Margin
    int
    Returns the bottom margin in pixel
    float
    getMarginFloatValue(boolean rtl, int orientation)
    Returns the Margin
    int
    getMarginLeft(boolean rtl)
    Returns the left margin in pixel or right margin in an RTL situation
    int
    Returns the left margin in pixels ignoring RTL
    int
    getMarginRight(boolean rtl)
    Returns the right margin in pixel or left margin in an RTL situation
    int
    Returns the right margin in pixels ignoring RTL
    int
    Returns the top margin in pixel
    byte[]
    Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,
    int
    getMarginValue(boolean rtl, int orientation)
    Returns the Margin
    int
    Returns the opacity value for the component
    int
    getPadding(boolean rtl, int orientation)
    Returns the Padding in using the current unit
    int
    getPadding(int orientation)
    Returns the Padding
    int
    Returns the bottom padding in pixel
    float
    getPaddingFloatValue(boolean rtl, int orientation)
    Returns the Padding in the internal value regardless of the unit
    int
    getPaddingLeft(boolean rtl)
    Returns the left padding in pixel or right padding in an RTL situation
    int
    Returns the left padding in pixels ignoring RTL
    int
    getPaddingRight(boolean rtl)
    Returns the right padding in pixel or left padding in an RTL situation
    int
    Returns the right padding in pixels ignoring RTL
    int
    Returns the top padding in pixel
    byte[]
    Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,
    int
    getPaddingValue(boolean rtl, int orientation)
    Returns the Padding in the internal value regardless of the unit
    int
    Returns the text decoration of this style
    int
    The equivalent of getMarginTop + getMarginBottom
    int
    The equivalent of getPaddingTop + getPaddingBottom
    int
     
    boolean
    Returns the text decoration state for the north
    boolean
    Returns true if the 3D text decoration is on, false otherwise
    boolean
    Returns true if the style was modified manually after it was created by the look and feel.
    boolean
    Returns true if the overline text decoration is on, false otherwise
    boolean
    Returns true if the 3D text decoration is on, false otherwise
    boolean
    Indicates whether this style has been marked for use with renderers.
    boolean
    Returns true if the strike through text decoration is on, false otherwise
    boolean
    Checks to see if change events are currently suppressed.
    boolean
    Checks whether the component is a surface.
    boolean
    Returns true if the underline text decoration is on, false otherwise
    void
    Disables native OS optimizations that might collide with cell renderers which do things like sharing style objects
    void
    merge(Style style)
    Merges the new style with the current style without changing the elements that were modified.
    void
    This method removes all Listeners from the Style
    void
    Removes a Style Listener from the Style Object.
    void
    Restore cached margins and flush the margins cache Warning: this method is used internally when unhidding a component with the Component.setHidden(false) method Do not use it on an hidden component or it would result into unexpected results when unhidding this component
    void
    set3DText(boolean t, boolean raised)
    Sets the 3D text decoration for this style
    void
    set3DTextNorth(boolean north)
    Sets the text decoration to 3D text
    void
    setAlignment(int align)
    Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
    void
    setAlignment(int align, boolean override)
    Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
    void
    setBackgroundGradientEndColor(int backgroundGradientEndColor)
    Sets the background color for the component
    void
    setBackgroundGradientEndColor(int backgroundGradientEndColor, boolean override)
    Sets the background color for the component
    void
    setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)
    Background radial gradient relative size
    void
    setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize, boolean override)
    Background radial gradient relative size
    void
    setBackgroundGradientRelativeX(float backgroundGradientRelativeX)
    Background radial gradient relative center position X
    void
    setBackgroundGradientRelativeX(float backgroundGradientRelativeX, boolean override)
    Background radial gradient relative center position X
    void
    setBackgroundGradientRelativeY(float backgroundGradientRelativeY)
    Background radial gradient relative center position Y
    void
    setBackgroundGradientRelativeY(float backgroundGradientRelativeY, boolean override)
    Background radial gradient relative center position Y
    void
    setBackgroundGradientStartColor(int backgroundGradientStartColor)
    Sets the background color for the component
    void
    setBackgroundGradientStartColor(int backgroundGradientStartColor, boolean override)
    Sets the background color for the component
    void
    setBackgroundType(byte backgroundType)
    Sets the background type for the component
    void
    setBackgroundType(byte backgroundType, boolean override)
    Sets the background type for the component
    void
    setBgColor(int bgColor)
    Sets the background color for the component
    void
    setBgColor(int bgColor, boolean override)
    Sets the background color for the component
    void
    setBgImage(Image bgImage)
    Sets the background image for the component
    void
    setBgImage(Image bgImage, boolean override)
    Sets the background image for the component
    void
    setBgPainter(Painter bgPainter)
    Defines the background painter for this style, normally this would be the internal image/color painter but can be user defined
    void
    setBgTransparency(byte transparency)
    Sets the Component transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.
    void
    setBgTransparency(int transparency)
    Sets the Component transparency level.
    void
    setBgTransparency(int transparency, boolean override)
    Sets the Component transparency level.
    void
    setBorder(Border border)
    Sets the border for the style
    void
    setBorder(Border border, boolean override)
    Sets the border for the style
    void
    setElevation(int elevation)
    Sets the elevation value.
    void
    setElevation(int elevation, boolean override)
    Sets the elevation value.
    void
    setFgAlpha(int fgAlpha)
    Sets the foreground alpha for the component
    void
    setFgAlpha(int fgAlpha, boolean override)
    Sets the foreground alpha for the component
    final void
    setFgColor(int fgColor)
    Sets the foreground color for the component
    final void
    setFgColor(int fgColor, boolean override)
    Sets the foreground color for the component
    void
    setFont(Font font)
    Sets the font for the component
    void
    setFont(Font font, boolean override)
    Sets the font for the component
    void
    setIconGap(float gap)
    Sets the icon gap in the current units.
    void
    setIconGap(float gap, boolean override)
    Sets the icon gap.
    void
    setIconGap(float gap, byte unit)
    Sets the icon gap.
    void
    setIconGap(float gap, byte units, boolean override)
    Sets the icon gap.
    void
    setIconGapUnit(byte unit)
    Sets the icon gap unit.
    void
    setIconGapUnit(byte unit, boolean override)
    Sets the icon gap unit.
    void
    setMargin(float top, float bottom, float left, float right)
    Sets the Style Margin
    void
    setMargin(int orientation, float gap)
    Sets the Style Margin
    void
    setMargin(int orientation, float gap, boolean override)
    Sets the Style Margin
    void
    setMargin(int orientation, int gap)
    Sets the Style Margin
    void
    setMargin(int orientation, int gap, boolean override)
    Sets the Style Margin
    void
    setMargin(int top, int bottom, int left, int right)
    Sets the Style Margin
    void
    setMarginBottom(float gap)
    Sets the Style Margin on the bottom, this is equivalent to calling setMargin(Component.BOTTOM, gap, false);
    void
    setMarginBottom(int gap)
    Sets the Style Margin on the bottom, this is equivalent to calling setMargin(Component.BOTTOM, gap, false);
    void
    setMarginLeft(float gap)
    Sets the Style Margin on the left, this is equivalent to calling setMargin(Component.LEFT, gap, false);
    void
    setMarginLeft(int gap)
    Sets the Style Margin on the left, this is equivalent to calling setMargin(Component.LEFT, gap, false);
    void
    setMarginRight(float gap)
    Sets the Style Margin on the right, this is equivalent to calling setMargin(Component.RIGHT, gap, false);
    void
    setMarginRight(int gap)
    Sets the Style Margin on the right, this is equivalent to calling setMargin(Component.RIGHT, gap, false);
    void
    setMarginTop(float gap)
    Sets the Style margin on the top, this is equivalent to calling setMargin(Component.TOP, gap, false);
    void
    setMarginTop(int gap)
    Sets the Style margin on the top, this is equivalent to calling setMargin(Component.TOP, gap, false);
    void
    setMarginUnit(byte... marginUnit)
    Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,
    void
    Sets bottom margin unit.
    void
    setMarginUnitLeft(byte unit)
    Sets left margin unit.
    void
    setMarginUnitRight(byte unit)
    Sets right margin unit.
    void
    setMarginUnitTop(byte unit)
    Sets top margin unit.
    final void
    setOpacity(int opacity)
    Set the opacity value
    final void
    setOpacity(int opacity, boolean override)
    Sets the Component transparency level.
    void
    setOverline(boolean overline)
    Sets the overline text decoration for this style
    void
    setPadding(float top, float bottom, float left, float right)
    Sets the Style Padding.
    void
    setPadding(int orientation, float gap)
    Sets the Style Padding.
    void
    setPadding(int orientation, float gap, boolean override)
    Sets the Style Padding
    void
    setPadding(int orientation, int gap)
    Sets the Style Padding.
    void
    setPadding(int orientation, int gap, boolean override)
    Sets the Style Padding
    void
    setPadding(int top, int bottom, int left, int right)
    Sets the Style Padding.
    void
    setPaddingBottom(float gap)
    Sets the Style Padding on the bottom, this is equivalent to calling setPadding(Component.BOTTOM, gap, false);
    void
    Sets the Style Padding on the bottom, this is equivalent to calling setPadding(Component.BOTTOM, gap, false);
    void
    setPaddingLeft(float gap)
    Sets the Style Padding on the left, this is equivalent to calling setPadding(Component.LEFT, gap, false);
    void
    setPaddingLeft(int gap)
    Sets the Style Padding on the left, this is equivalent to calling setPadding(Component.LEFT, gap, false);
    void
    setPaddingRight(float gap)
    Sets the Style Padding on the right, this is equivalent to calling setPadding(Component.RIGHT, gap, false);
    void
    setPaddingRight(int gap)
    Sets the Style Padding on the right, this is equivalent to calling setPadding(Component.RIGHT, gap, false);
    void
    setPaddingTop(float gap)
    Sets the Style Padding on the top, this is equivalent to calling setPadding(Component.TOP, gap, false);
    void
    setPaddingTop(int gap)
    Sets the Style Padding on the top, this is equivalent to calling setPadding(Component.TOP, gap, false);
    void
    setPaddingUnit(byte... paddingUnit)
    Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
    void
    Sets bottom padding unit.
    void
    setPaddingUnitLeft(byte unit)
    Sets left padding unit.
    void
    Sets right padding unit.
    void
    setPaddingUnitTop(byte unit)
    Sets top padding unit.
    void
    setStrikeThru(boolean strikethru)
    Sets the strike through text decoration for this style
    void
    setSuppressChangeEvents(boolean suppress)
    Enables or disables events.
    void
    setSurface(boolean surface)
    Enables or disables surface rendering mode for component.
    void
    setSurface(boolean surface, boolean override)
    Enables or disables surface rendering mode for component.
    void
    setTextDecoration(int textDecoration)
    Sets the text decoration of this style
    void
    setTextDecoration(int textDecoration, boolean override)
    Sets the text decoration of this style
    void
    setUnderline(boolean underline)
    Sets the underline text decoration for this style
    void
    Strips all margin and padding from this style.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BG_COLOR

      public static final String BG_COLOR
      Background color attribute name for the theme hashtable
      See Also:
    • FG_COLOR

      public static final String FG_COLOR
      Foreground color attribute name for the theme hashtable
      See Also:
    • FG_ALPHA

      public static final String FG_ALPHA
      Foreground alpha attribute name for the theme hashtable
      See Also:
    • BG_IMAGE

      public static final String BG_IMAGE
      Background image attribute name for the theme hashtable
      See Also:
    • BACKGROUND_TYPE

      public static final String BACKGROUND_TYPE
      Background attribute name for the theme hashtable
      See Also:
    • BACKGROUND_ALIGNMENT

      public static final String BACKGROUND_ALIGNMENT
      Background attribute name for the theme hashtable
      See Also:
    • BACKGROUND_GRADIENT

      public static final String BACKGROUND_GRADIENT
      Background attribute name for the theme hashtable
      See Also:
    • FONT

      public static final String FONT
      Font attribute name for the theme hashtable
      See Also:
    • TRANSPARENCY

      public static final String TRANSPARENCY
      Transparency attribute name for the theme hashtable
      See Also:
    • OPACITY

      public static final String OPACITY
      Opacity attribute name for the theme hashtable
      See Also:
    • ELEVATION

      public static final String ELEVATION
      Elevation attribute name for the theme hashtable.
      See Also:
    • ICON_GAP

      public static final String ICON_GAP

      Icon gap attribute name for the theme hashtable.

      Since

      8.0

      See Also:
    • ICON_GAP_UNIT

      public static final String ICON_GAP_UNIT

      Icon gap unit attribute.

      Since

      8.0

      See Also:
    • SURFACE

      public static final String SURFACE
      Surface attribute name for the theme hashtable.
      See Also:
    • MARGIN

      public static final String MARGIN
      Margin attribute name for the theme hashtable
      See Also:
    • BORDER

      public static final String BORDER
      Border attribute name for the theme hashtable
      See Also:
    • PADDING

      public static final String PADDING
      Padding attribute name for the theme hashtable
      See Also:
    • PAINTER

      public static final String PAINTER
      Painter attribute name for the style event
      See Also:
    • ALIGNMENT

      public static final String ALIGNMENT
      Alignment attribute for the style event
      See Also:
    • TEXT_DECORATION

      public static final String TEXT_DECORATION
      Text decoration attribute for the style event
      See Also:
    • PADDING_UNIT

      public static final String PADDING_UNIT
      The units of the padding
      See Also:
    • MARGIN_UNIT

      public static final String MARGIN_UNIT
      The units of the margin
      See Also:
    • BACKGROUND_NONE

      public static final byte BACKGROUND_NONE
      Indicates the background for the style would use a scaled image
      See Also:
    • BACKGROUND_IMAGE_SCALED

      public static final byte BACKGROUND_IMAGE_SCALED
      Indicates the background for the style would use a scaled image
      See Also:
    • BACKGROUND_IMAGE_TILE_BOTH

      public static final byte BACKGROUND_IMAGE_TILE_BOTH
      Indicates the background for the style would use a tiled image on both axis
      See Also:
    • BACKGROUND_IMAGE_TILE_VERTICAL

      public static final byte BACKGROUND_IMAGE_TILE_VERTICAL
      Indicates the background for the style would use a vertical tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_HORIZONTAL

      public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_TOP

      public static final byte BACKGROUND_IMAGE_ALIGNED_TOP
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_BOTTOM

      public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_LEFT

      public static final byte BACKGROUND_IMAGE_ALIGNED_LEFT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_RIGHT

      public static final byte BACKGROUND_IMAGE_ALIGNED_RIGHT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_CENTER

      public static final byte BACKGROUND_IMAGE_ALIGNED_CENTER
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_TOP_LEFT

      public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_LEFT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT

      public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT

      public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT

      public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT
      Indicates the background for the style would use an unscaled image with an alignment
      See Also:
    • BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP

      public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER

      public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM

      public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT

      public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER

      public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT

      public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT
      Indicates the background for the style would use a horizontal tiled image
      See Also:
    • BACKGROUND_IMAGE_SCALED_FILL

      public static final byte BACKGROUND_IMAGE_SCALED_FILL
      Indicates the background for the style would use a scaled image that fills all available space while maintaining aspect ratio
      See Also:
    • BACKGROUND_IMAGE_SCALED_FIT

      public static final byte BACKGROUND_IMAGE_SCALED_FIT
      Indicates the background for the style would use a scaled image that fits to available space while maintaining aspect ratio
      See Also:
    • BACKGROUND_GRADIENT_LINEAR_VERTICAL

      public static final byte BACKGROUND_GRADIENT_LINEAR_VERTICAL
      Indicates the background for the style would use a linear gradient
      See Also:
    • BACKGROUND_GRADIENT_LINEAR_HORIZONTAL

      public static final byte BACKGROUND_GRADIENT_LINEAR_HORIZONTAL
      Indicates the background for the style would use a linear gradient
      See Also:
    • BACKGROUND_GRADIENT_RADIAL

      public static final byte BACKGROUND_GRADIENT_RADIAL
      Indicates the background for the style would use a radial gradient
      See Also:
    • TEXT_DECORATION_NONE

      public static final byte TEXT_DECORATION_NONE
      Indicates no text decoration
      See Also:
    • TEXT_DECORATION_UNDERLINE

      public static final byte TEXT_DECORATION_UNDERLINE
      Indicates underline
      See Also:
    • TEXT_DECORATION_STRIKETHRU

      public static final byte TEXT_DECORATION_STRIKETHRU
      Indicates a strike-through line (usually used to denote deleted text)
      See Also:
    • TEXT_DECORATION_OVERLINE

      public static final byte TEXT_DECORATION_OVERLINE
      Indicates overline
      See Also:
    • TEXT_DECORATION_3D

      public static final byte TEXT_DECORATION_3D
      3D text effect using a font shadow
      See Also:
    • TEXT_DECORATION_3D_LOWERED

      public static final byte TEXT_DECORATION_3D_LOWERED
      3D sunken text effect using a light font shadow
      See Also:
    • TEXT_DECORATION_3D_SHADOW_NORTH

      public static final byte TEXT_DECORATION_3D_SHADOW_NORTH
      3D text effect using a font shadow
      See Also:
    • UNIT_TYPE_PIXELS

      public static final byte UNIT_TYPE_PIXELS
      Indicates the unit type for padding/margin, the default is in device specific pixels
      See Also:
    • UNIT_TYPE_SCREEN_PERCENTAGE

      public static final byte UNIT_TYPE_SCREEN_PERCENTAGE
      Indicates the unit type for padding/margin in percentage of the size of the screen
      See Also:
    • UNIT_TYPE_DIPS

      public static final byte UNIT_TYPE_DIPS
      Indicates the unit type for padding/margin in device independent pixels. Device independent pixels try to aim at roughly 1 millimeter of the screen per DIP but make no guarantee for accuracy.
      See Also:
    • UNIT_TYPE_VW

      public static final byte UNIT_TYPE_VW

      Indicates the unit type for padding/margin as a percentage of the screen width.

      Since

      8.0

      See Also:
    • UNIT_TYPE_VH

      public static final byte UNIT_TYPE_VH

      Indicates the unit type for padding/margin as a percentage of the screen height.

      Since

      8.0

      See Also:
    • UNIT_TYPE_VMIN

      public static final byte UNIT_TYPE_VMIN

      Indicates the unit type for padding/margin as a percentage the minimum of screen width and height.

      Since

      8.0

      See Also:
    • UNIT_TYPE_VMAX

      public static final byte UNIT_TYPE_VMAX

      Indicates the unit type for padding/margin as a percentage the maximum of screen width and height.

      Since

      8.0

      See Also:
    • UNIT_TYPE_REM

      public static final byte UNIT_TYPE_REM

      Indicates the unit type for padding/margin relative to the font size of the default font. 1rem == Font.getDefaultFont().getHeight()

      Since

      8.0

      See Also:
  • Constructor Details

    • Style

      public Style()
      Each component when it draw itself uses this Object to determine in what colors it should use. When a Component is generated it construct a default Style Object. The Default values for each Component can be changed by using the UIManager class
    • Style

      public Style(Style style)

      Creates a full copy of the given style. Notice that if the original style was modified manually (by invoking setters on it) it would not chnage when changing a theme/look and feel, however this newly created style would change in such a case.

      Parameters
      • style: the style to copy
    • Style

      public Style(int fgColor, int bgColor, Font f, byte transparency)

      Creates a new style with the given attributes

      Parameters
      • fgColor: foreground color

      • bgColor: background color

      • f: font

      • transparency: transparency value

    • Style

      public Style(int fgColor, int bgColor, Font f, byte transparency, Image im, byte backgroundType)

      Creates a new style with the given attributes

      Parameters
      • fgColor: foreground color

      • bgColor: background color

      • f: font

      • transparency: transparency value

      • im: background image

      • backgroundType: @param backgroundType one of: BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL

  • Method Details

    • createProxyStyle

      public static Style createProxyStyle(Style... styles)

      Creates a "proxy" style whose setter methods map to the methods in the given styles passed and whose getter methods are meaningless

      Parameters
      • styles: the styles to which we will proxy
      Returns

      a proxy style object

    • markAsRendererStyle

      public void markAsRendererStyle()
      Disables native OS optimizations that might collide with cell renderers which do things like sharing style objects
    • isRendererStyle

      public boolean isRendererStyle()

      Indicates whether this style has been marked for use with renderers.

      Returns

      true if #markAsRendererStyle() was invoked.

    • merge

      public void merge(Style style)

      Merges the new style with the current style without changing the elements that were modified.

      Parameters
      • style: new values of styles from the current theme
    • getElevation

      public int getElevation()

      Gets the elevation value of this style. Valid values include 0, 1, 2, 3, 4, 6, 8, 9, 12, 16, and 24.

      Returns

      The elevation value. Default is 0.

      Since

      8.0

    • setElevation

      public void setElevation(int elevation)

      Sets the elevation value. Valid values include 0, 1, 2, 3, 4, 6, 8, 9, 12, 16, and 24.

      Parameters
      • elevation: The elevation value.
      Since

      8.0

    • getIconGap

      public int getIconGap()

      Returns the icon gap in pixels.

      Since

      8.0

    • setIconGap

      public void setIconGap(float gap)

      Sets the icon gap in the current units.

      Parameters
      • gap: The icon gap.
      Since

      8.0

      See also
      • #getIconGapUnit()
    • getIconGapUnit

      public int getIconGapUnit()

      Returns the icon gap unit. One of #UNIT_TYPE_REM, #UNIT_TYPE_VMAX, #UNIT_TYPE_VMIN, #UNIT_TYPE_VH, #UNIT_TYPE_VW, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_DIPS, #UNIT_TYPE_PIXELS

      Returns

      The icon gap unit

      Since

      8.0

    • setIconGapUnit

      public void setIconGapUnit(byte unit)

      Sets the icon gap unit.

      Parameters
      • unit: The icon gap unit. One of the standard style units of measurement.
      Since

      8.0

    • isSurface

      public boolean isSurface()

      Checks whether the component is a surface. Surface containers support a sort of z-index of descendants via the elevation attribute. Surfaces will render the shadows of elevated descendants to convey depth.

      Returns

      True if container should be rendered as a surface.

      Since

      8.0

    • setSurface

      public void setSurface(boolean surface)

      Enables or disables surface rendering mode for component. Surfaces can support a sort of z-indexing of its descendants via their elevation properties. The surface will render the shadows of elevated descendants to convey depth.

      Parameters
      • surface: True to enable surface rendering mode.
      Since

      8.0

    • isModified

      public boolean isModified()

      Returns true if the style was modified manually after it was created by the look and feel. If the style was modified manually (by one of the set methods) then it should be merged rather than overwritten.

      Returns

      true if the style was modified

    • getBgColor

      public int getBgColor()

      Background color for the component

      Returns

      the background color for the component

    • setBgColor

      public void setBgColor(int bgColor)

      Sets the background color for the component

      Parameters
      • bgColor: RRGGBB color that ignors the alpha component
    • getBgImage

      public Image getBgImage()

      Background image for the component

      Returns

      the background image for the component

    • setBgImage

      public void setBgImage(Image bgImage)

      Sets the background image for the component

      Parameters
      • bgImage: background image
    • getBackgroundType

      public byte getBackgroundType()

      The type of the background defaults to BACKGROUND_IMAGE_SCALED

      Returns
      Returns:
      one of: BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL
    • setBackgroundType

      public void setBackgroundType(byte backgroundType)

      Sets the background type for the component

      Parameters
      • backgroundType: @param backgroundType one of BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL
    • getBackgroundGradientStartColor

      public int getBackgroundGradientStartColor()

      Start color for the radial/linear gradient

      Returns

      the start color for the radial/linear gradient

    • setBackgroundGradientStartColor

      public void setBackgroundGradientStartColor(int backgroundGradientStartColor)

      Sets the background color for the component

      Parameters
      • backgroundGradientStartColor: start color for the linear/radial gradient
    • getBackgroundGradientEndColor

      public int getBackgroundGradientEndColor()

      End color for the radial/linear gradient

      Returns

      the end color for the radial/linear gradient

    • setBackgroundGradientEndColor

      public void setBackgroundGradientEndColor(int backgroundGradientEndColor)

      Sets the background color for the component

      Parameters
      • backgroundGradientEndColor: end color for the linear/radial gradient
    • getBackgroundGradientRelativeX

      public float getBackgroundGradientRelativeX()

      Background radial gradient relative center position X

      Returns

      value between 0 and 1 with 0.5 representing the center of the component

    • setBackgroundGradientRelativeX

      public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX)

      Background radial gradient relative center position X

      Parameters
      • backgroundGradientRelativeX: x position of the radial gradient center
    • getBackgroundGradientRelativeY

      public float getBackgroundGradientRelativeY()

      Background radial gradient relative center position Y

      Returns

      value between 0 and 1 with 0.5 representing the center of the component

    • setBackgroundGradientRelativeY

      public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY)

      Background radial gradient relative center position Y

      Parameters
      • backgroundGradientRelativeY: y position of the radial gradient center
    • getBackgroundGradientRelativeSize

      public float getBackgroundGradientRelativeSize()

      Background radial gradient relative size

      Returns

      value representing the relative size of the gradient

    • setBackgroundGradientRelativeSize

      public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)

      Background radial gradient relative size

      Parameters
      • backgroundGradientRelativeSize: the size of the radial gradient
    • getFgColor

      public int getFgColor()

      Foreground color for the component

      Returns

      the foreground color for the component

    • setFgColor

      public final void setFgColor(int fgColor)

      Sets the foreground color for the component

      Parameters
      • fgColor: foreground color
    • getFgAlpha

      public int getFgAlpha()

      Foreground alpha for the component

      Returns

      the foreground alpha for the component

      Since

      8.0

    • setFgAlpha

      public void setFgAlpha(int fgAlpha)

      Sets the foreground alpha for the component

      Parameters
      • fgAlpha: foreground alpha
    • getFont

      public Font getFont()

      Font for the component

      Returns

      the font for the component

    • setFont

      public void setFont(Font font)

      Sets the font for the component

      Parameters
      • font: the font
    • setElevation

      public void setElevation(int elevation, boolean override)

      Sets the elevation value. Valid values include 0, 1, 2, 3, 4, 6, 8, 9, 12, 16, and 24.

      Parameters
      • elevation: The elevation value.

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      Since

      8.0

    • setIconGap

      public void setIconGap(float gap, byte units, boolean override)

      Sets the icon gap.

      Parameters
      • gap: The gap.

      • units: The units of the gap.

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      Since

      8.0

      See also
      • #setIconGapUnit(byte, boolean)
    • setIconGap

      public void setIconGap(float gap, boolean override)

      Sets the icon gap.

      Parameters
      • gap: the icon gap.

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      Since

      8.0

      See also
      • #setIconGapUnit(byte, boolean)
    • setIconGap

      public void setIconGap(float gap, byte unit)

      Sets the icon gap.

      Parameters
      • gap: The icon gap.

      • unit: The unit. One of the standard style units of measurement.

      Since

      8.0

    • setIconGapUnit

      public void setIconGapUnit(byte unit, boolean override)

      Sets the icon gap unit.

      Parameters
      • unit: The icon gap unit. One of the standard style units of measurement.

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      Since

      8.0

    • setSurface

      public void setSurface(boolean surface, boolean override)

      Enables or disables surface rendering mode for component. Surfaces can support a sort of z-indexing of its descendants via their elevation properties. The surface will render the shadows of elevated descendants to convey depth.

      Parameters
      • surface: True to enable surface rendering mode.

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      Since

      8.0

    • setAlignment

      public void setAlignment(int align, boolean override)

      Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT

      Parameters
      • align: alignment value

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

      See also
      • com.codename1.ui.Component#CENTER

      • com.codename1.ui.Component#LEFT

      • com.codename1.ui.Component#RIGHT

    • getAlignment

      public int getAlignment()

      Returns the alignment of the Label

      Returns

      the alignment of the Label one of: CENTER, LEFT, RIGHT

      See also
      • com.codename1.ui.Component#CENTER

      • com.codename1.ui.Component#LEFT

      • com.codename1.ui.Component#RIGHT

    • setAlignment

      public void setAlignment(int align)

      Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT

      Parameters
      • align: alignment value
      See also
      • com.codename1.ui.Component#CENTER

      • com.codename1.ui.Component#LEFT

      • com.codename1.ui.Component#RIGHT

    • isUnderline

      public boolean isUnderline()

      Returns true if the underline text decoration is on, false otherwise

      Returns

      true if the underline text decoration is on, false otherwise

    • setUnderline

      public void setUnderline(boolean underline)

      Sets the underline text decoration for this style

      Parameters
      • underline: true to turn underline on, false to turn it off
    • set3DText

      public void set3DText(boolean t, boolean raised)

      Sets the 3D text decoration for this style

      Parameters
      • t: true to turn 3d shadow effect on, false to turn it off

      • raised: indicates a raised or lowered effect

    • is3DTextNorth

      public boolean is3DTextNorth()

      Returns the text decoration state for the north

      Returns

      true if that is used

    • set3DTextNorth

      public void set3DTextNorth(boolean north)

      Sets the text decoration to 3D text

      Parameters
      • north: true to enable 3d text with the shadow on top false otherwise
    • isRaised3DText

      public boolean isRaised3DText()

      Returns true if the 3D text decoration is on, false otherwise

      Returns

      true if the 3D text decoration is on, false otherwise

    • isLowered3DText

      public boolean isLowered3DText()

      Returns true if the 3D text decoration is on, false otherwise

      Returns

      true if the 3D text decoration is on, false otherwise

    • isOverline

      public boolean isOverline()

      Returns true if the overline text decoration is on, false otherwise

      Returns

      true if the overline text decoration is on, false otherwise

    • setOverline

      public void setOverline(boolean overline)

      Sets the overline text decoration for this style

      Parameters
      • overline: true to turn overline on, false to turn it off
    • isStrikeThru

      public boolean isStrikeThru()

      Returns true if the strike through text decoration is on, false otherwise

      Returns

      true if the strike through text decoration is on, false otherwise

    • setStrikeThru

      public void setStrikeThru(boolean strikethru)

      Sets the strike through text decoration for this style

      Parameters
      • strikethru: true to turn strike through on, false to turn it off
    • getTextDecoration

      public int getTextDecoration()

      Returns the text decoration of this style

      Returns

      the text decoration of this style (bitmask of the TEXT_DECORATION_* constants)

    • setTextDecoration

      public void setTextDecoration(int textDecoration)

      Sets the text decoration of this style

      Parameters
      • textDecoration: the textDecoration to set (bitmask of the TEXT_DECORATION_* constants)
    • setTextDecoration

      public void setTextDecoration(int textDecoration, boolean override)

      Sets the text decoration of this style

      Parameters
      • textDecoration: the textDecoration to set (bitmask of the TEXT_DECORATION_* constants)

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • getBgTransparency

      public byte getBgTransparency()

      Returns the transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.

      Returns

      the transparency level of the Component

    • setBgTransparency

      public void setBgTransparency(byte transparency)

      Sets the Component transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.

      Parameters
      • transparency: transparency level as byte
    • setBgTransparency

      public void setBgTransparency(int transparency)

      Sets the Component transparency level. Valid values should be a number between 0-255

      Parameters
      • transparency: int value between 0-255
    • getOpacity

      public int getOpacity()

      Returns the opacity value for the component

      Returns

      the opacity value

    • setOpacity

      public final void setOpacity(int opacity)

      Set the opacity value

      Parameters
      • opacity: the opacity value
    • setOpacity

      public final void setOpacity(int opacity, boolean override)

      Sets the Component transparency level. Valid values should be a number between 0-255

      Parameters
      • opacity: int value between 0-255

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • stripMarginAndPadding

      public void stripMarginAndPadding()

      Strips all margin and padding from this style.

      Since

      7.0

    • setPadding

      public void setPadding(int top, int bottom, int left, int right)

      Sets the Style Padding. Units are specified by #setPaddingUnit(byte...)

      Parameters
      • top: number of units to pad the top

      • bottom: number of units to pad the bottom

      • left: number of units to pad the left

      • right: number of units to pad the right

      See also
      • #setPaddingUnit(byte...)
    • setPadding

      public void setPadding(float top, float bottom, float left, float right)

      Sets the Style Padding. Units are specified by #setPaddingUnit(byte...)

      Parameters
      • top: number of units to pad the top

      • bottom: number of units to pad the bottom

      • left: number of units to pad the left

      • right: number of units to pad the right

      See also
      • #setPaddingUnit(byte...)
    • setPadding

      public void setPadding(int orientation, int gap)

      Sets the Style Padding. Units are specified by #setPaddingUnit(byte...)

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of units to pad the orientation

    • setPadding

      public void setPadding(int orientation, float gap)

      Sets the Style Padding. Units are specified by #setPaddingUnit(byte...)

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of units to pad the orientation

    • setMargin

      public void setMargin(int top, int bottom, int left, int right)

      Sets the Style Margin

      Parameters
      • top: number of margin using the current unit

      • bottom: number of margin using the current unit

      • left: number of margin using the current unit

      • right: number of margin using the current unit

    • setMargin

      public void setMargin(float top, float bottom, float left, float right)

      Sets the Style Margin

      Parameters
      • top: number of margin using the current unit

      • bottom: number of margin using the current unit

      • left: number of margin using the current unit

      • right: number of margin using the current unit

    • cacheMargins

      public void cacheMargins(boolean override)
      Store current margin values into a cache that could be restored with restoreCachedMargins()
    • restoreCachedMargins

      public void restoreCachedMargins()
      Restore cached margins and flush the margins cache Warning: this method is used internally when unhidding a component with the Component.setHidden(false) method Do not use it on an hidden component or it would result into unexpected results when unhidding this component
    • flushMarginsCache

      public void flushMarginsCache()
      Flush the margins cache if one exists
    • setMargin

      public void setMargin(int orientation, int gap)

      Sets the Style Margin

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of margin using the current unit

    • setMargin

      public void setMargin(int orientation, float gap)

      Sets the Style Margin

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of margin using the current unit

    • getPaddingValue

      public int getPaddingValue(boolean rtl, int orientation)

      Returns the Padding in the internal value regardless of the unit

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      amount of padding in the given orientation using current units.

      Deprecated

      Use int)

      See also
      • #getPaddingUnit()
    • getPaddingFloatValue

      public float getPaddingFloatValue(boolean rtl, int orientation)

      Returns the Padding in the internal value regardless of the unit

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      amount of padding in the given orientation using current units.

      Since

      8.0

      See also
      • #getPaddingUnit()
    • getPaddingLeft

      public int getPaddingLeft(boolean rtl)

      Returns the left padding in pixel or right padding in an RTL situation

      Parameters
      • rtl: indicates a right to left language
      Returns

      the padding in pixels

    • setPaddingUnitLeft

      public void setPaddingUnitLeft(byte unit)

      Sets left padding unit.

      Parameters
      • unit: @param unit One of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setPaddingUnitRight

      public void setPaddingUnitRight(byte unit)

      Sets right padding unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setPaddingUnitTop

      public void setPaddingUnitTop(byte unit)

      Sets top padding unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setPaddingUnitBottom

      public void setPaddingUnitBottom(byte unit)

      Sets bottom padding unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • getPaddingRight

      public int getPaddingRight(boolean rtl)

      Returns the right padding in pixel or left padding in an RTL situation

      Parameters
      • rtl: indicates a right to left language
      Returns

      the padding in pixels

    • getPaddingTop

      public int getPaddingTop()

      Returns the top padding in pixel

      Returns

      the padding in pixels

    • setPaddingTop

      public void setPaddingTop(int gap)

      Sets the Style Padding on the top, this is equivalent to calling setPadding(Component.TOP, gap, false);

      Parameters
      • gap: amount to pad the top in current units.
      See also
      • #getPaddingUnit()
    • setPaddingTop

      public void setPaddingTop(float gap)

      Sets the Style Padding on the top, this is equivalent to calling setPadding(Component.TOP, gap, false);

      Parameters
      • gap: Amount to pad the top in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setPaddingLeft

      public void setPaddingLeft(int gap)

      Sets the Style Padding on the left, this is equivalent to calling setPadding(Component.LEFT, gap, false);

      Parameters
      • gap: Amount to pad the left in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setPaddingLeft

      public void setPaddingLeft(float gap)

      Sets the Style Padding on the left, this is equivalent to calling setPadding(Component.LEFT, gap, false);

      Parameters
      • gap: Amount to pad the left in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setPaddingRight

      public void setPaddingRight(int gap)

      Sets the Style Padding on the right, this is equivalent to calling setPadding(Component.RIGHT, gap, false);

      Parameters
      • gap: Amount to pad the right in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setPaddingRight

      public void setPaddingRight(float gap)

      Sets the Style Padding on the right, this is equivalent to calling setPadding(Component.RIGHT, gap, false);

      Parameters
      • gap: Amount to pad the right in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setMarginLeft

      public void setMarginLeft(int gap)

      Sets the Style Margin on the left, this is equivalent to calling setMargin(Component.LEFT, gap, false);

      Parameters
      • gap: number of left margin using the current unit
    • setMarginLeft

      public void setMarginLeft(float gap)

      Sets the Style Margin on the left, this is equivalent to calling setMargin(Component.LEFT, gap, false);

      Parameters
      • gap: number of left margin using the current unit
    • setMarginRight

      public void setMarginRight(int gap)

      Sets the Style Margin on the right, this is equivalent to calling setMargin(Component.RIGHT, gap, false);

      Parameters
      • gap: number of right margin using the current unit
    • setMarginRight

      public void setMarginRight(float gap)

      Sets the Style Margin on the right, this is equivalent to calling setMargin(Component.RIGHT, gap, false);

      Parameters
      • gap: number of right margin using the current unit
    • getPaddingBottom

      public int getPaddingBottom()

      Returns the bottom padding in pixel

      Returns

      the padding in pixels

    • setPaddingBottom

      public void setPaddingBottom(int gap)

      Sets the Style Padding on the bottom, this is equivalent to calling setPadding(Component.BOTTOM, gap, false);

      Parameters
      • gap: Amount to pad the bottom in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • setPaddingBottom

      public void setPaddingBottom(float gap)

      Sets the Style Padding on the bottom, this is equivalent to calling setPadding(Component.BOTTOM, gap, false);

      Parameters
      • gap: Amount to pad the bottom in current units.
      See also
      • #getPaddingUnit()

      • #setPaddingUnit(byte...)

    • getHorizontalMargins

      public int getHorizontalMargins()

      The equivalent of getMarginLeft + getMarginRight

      Returns

      the side margin

    • getVerticalMargins

      public int getVerticalMargins()

      The equivalent of getMarginTop + getMarginBottom

      Returns

      the vertical margin

    • getHorizontalPadding

      public int getHorizontalPadding()

      The equivalent of getPaddingLeft + getPaddingRight

      Returns

      the side padding

    • getVerticalPadding

      public int getVerticalPadding()

      The equivalent of getPaddingTop + getPaddingBottom

      Returns

      the vertical padding

    • getMarginRightNoRTL

      public int getMarginRightNoRTL()

      Returns the right margin in pixels ignoring RTL

      Returns

      the margin in pixels

    • getMarginLeftNoRTL

      public int getMarginLeftNoRTL()

      Returns the left margin in pixels ignoring RTL

      Returns

      the margin in pixels

    • getPaddingRightNoRTL

      public int getPaddingRightNoRTL()

      Returns the right padding in pixels ignoring RTL

      Returns

      the padding in pixels

    • getPaddingLeftNoRTL

      public int getPaddingLeftNoRTL()

      Returns the left padding in pixels ignoring RTL

      Returns

      the padding in pixels

    • getMarginRight

      public int getMarginRight(boolean rtl)

      Returns the right margin in pixel or left margin in an RTL situation

      Parameters
      • rtl: indicates a right to left language
      Returns

      the margin in pixels

    • getMarginLeft

      public int getMarginLeft(boolean rtl)

      Returns the left margin in pixel or right margin in an RTL situation

      Parameters
      • rtl: indicates a right to left language
      Returns

      the margin in pixels

    • getMarginTop

      public int getMarginTop()

      Returns the top margin in pixel

      Returns

      the margin in pixels

    • setMarginTop

      public void setMarginTop(int gap)

      Sets the Style margin on the top, this is equivalent to calling setMargin(Component.TOP, gap, false);

      Parameters
      • gap: number of top margin using the current unit
    • setMarginTop

      public void setMarginTop(float gap)

      Sets the Style margin on the top, this is equivalent to calling setMargin(Component.TOP, gap, false);

      Parameters
      • gap: number of top margin using the current unit
    • getMarginBottom

      public int getMarginBottom()

      Returns the bottom margin in pixel

      Returns

      the margin in pixels

    • setMarginBottom

      public void setMarginBottom(int gap)

      Sets the Style Margin on the bottom, this is equivalent to calling setMargin(Component.BOTTOM, gap, false);

      Parameters
      • gap: number of bottom margin using the current unit
    • setMarginBottom

      public void setMarginBottom(float gap)

      Sets the Style Margin on the bottom, this is equivalent to calling setMargin(Component.BOTTOM, gap, false);

      Parameters
      • gap: number of bottom margin using the current unit
    • getPadding

      public int getPadding(boolean rtl, int orientation)

      Returns the Padding in using the current unit

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      number of padding pixels in the given orientation

    • getPadding

      public int getPadding(int orientation)

      Returns the Padding

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
      Returns

      number of padding pixels in the given orientation

    • getMargin

      public int getMargin(int orientation)

      Returns the Margin

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
      Returns

      number of margin using the current unit in the given orientation

    • getMargin

      public int getMargin(boolean rtl, int orientation)

      Returns the Margin

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      number of margin using the current unit in the given orientation

    • getMarginValue

      public int getMarginValue(boolean rtl, int orientation)

      Returns the Margin

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      number of margin using the current unit in the given orientation

      Deprecated

      Use int)

    • getMarginFloatValue

      public float getMarginFloatValue(boolean rtl, int orientation)

      Returns the Margin

      Parameters
      • rtl: flag indicating whether the padding is for an RTL bidi component

      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      Returns

      number of margin using the current unit in the given orientation

      Since

      8.0

    • setBgColor

      public void setBgColor(int bgColor, boolean override)

      Sets the background color for the component

      Parameters
      • bgColor: RRGGBB color that ignores the alpha component

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBgImage

      public void setBgImage(Image bgImage, boolean override)

      Sets the background image for the component

      Parameters
      • bgImage: background image

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundType

      public void setBackgroundType(byte backgroundType, boolean override)

      Sets the background type for the component

      Parameters
      • backgroundType: @param backgroundType one of BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundGradientStartColor

      public void setBackgroundGradientStartColor(int backgroundGradientStartColor, boolean override)

      Sets the background color for the component

      Parameters
      • backgroundGradientStartColor: start color for the linear/radial gradient

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundGradientEndColor

      public void setBackgroundGradientEndColor(int backgroundGradientEndColor, boolean override)

      Sets the background color for the component

      Parameters
      • backgroundGradientEndColor: end color for the linear/radial gradient

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundGradientRelativeX

      public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX, boolean override)

      Background radial gradient relative center position X

      Parameters
      • backgroundGradientRelativeX: x position of the radial gradient center

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundGradientRelativeY

      public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY, boolean override)

      Background radial gradient relative center position Y

      Parameters
      • backgroundGradientRelativeY: y position of the radial gradient center

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBackgroundGradientRelativeSize

      public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize, boolean override)

      Background radial gradient relative size

      Parameters
      • backgroundGradientRelativeSize: @param backgroundGradientRelativeSize the size of the radial gradient relative to the screens larger dimension

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setFgColor

      public final void setFgColor(int fgColor, boolean override)

      Sets the foreground color for the component

      Parameters
      • fgColor: foreground color

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setFgAlpha

      public void setFgAlpha(int fgAlpha, boolean override)

      Sets the foreground alpha for the component

      Parameters
      • fgAlpha: foreground alpha

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setFont

      public void setFont(Font font, boolean override)

      Sets the font for the component

      Parameters
      • font: the font

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setBgTransparency

      public void setBgTransparency(int transparency, boolean override)

      Sets the Component transparency level. Valid values should be a number between 0-255

      Parameters
      • transparency: int value between 0-255

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setPadding

      public void setPadding(int orientation, int gap, boolean override)

      Sets the Style Padding

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of pixels to pad the orientation

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setPadding

      public void setPadding(int orientation, float gap, boolean override)

      Sets the Style Padding

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of pixels to pad the orientation

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setMargin

      public void setMargin(int orientation, int gap, boolean override)

      Sets the Style Margin

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of margin using the current unit

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • setMargin

      public void setMargin(int orientation, float gap, boolean override)

      Sets the Style Margin

      Parameters
      • orientation: one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT

      • gap: number of margin using the current unit

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • isSuppressChangeEvents

      public boolean isSuppressChangeEvents()

      Checks to see if change events are currently suppressed.

      Returns

      True if change events are suppressed.

      Since

      7.0

    • setSuppressChangeEvents

      public void setSuppressChangeEvents(boolean suppress)

      Enables or disables events. Use this to temporarily suppress change events.

      Parameters
      • suppress: True to suppress change events.
      Since

      7.0

    • addStyleListener

      public void addStyleListener(StyleListener l)

      Adds a Style Listener to the Style Object.

      Parameters
      • l: a style listener
    • removeStyleListener

      public void removeStyleListener(StyleListener l)

      Removes a Style Listener from the Style Object.

      Parameters
      • l: a style listener
    • removeListeners

      public void removeListeners()
      This method removes all Listeners from the Style
    • setBorder

      public void setBorder(Border border, boolean override)

      Sets the border for the style

      Parameters
      • border: new border object for the component

      • override: @param override If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

    • getBorder

      public Border getBorder()

      Returns the border for the style

      Returns

      the border

    • setBorder

      public void setBorder(Border border)

      Sets the border for the style

      Parameters
      • border: new border object for the component
    • getBgPainter

      public Painter getBgPainter()

      Return the background painter for this style, normally this would be the internal image/color painter but can be user defined

      Returns

      the background painter

    • setBgPainter

      public void setBgPainter(Painter bgPainter)

      Defines the background painter for this style, normally this would be the internal image/color painter but can be user defined

      Parameters
      • bgPainter: new painter to install into the style
    • getPaddingUnit

      public byte[] getPaddingUnit()

      Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,

      • #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Returns

      the paddingUnit

    • setPaddingUnit

      public void setPaddingUnit(byte... paddingUnit)

      Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.

      Parameters
      • paddingUnit: the paddingUnit to set
    • getMarginUnit

      public byte[] getMarginUnit()

      Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,

      • #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Returns

      the marginUnit

    • setMarginUnit

      public void setMarginUnit(byte... marginUnit)

      Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH,

      • #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Parameters
      • marginUnit: the marginUnit to set
    • setMarginUnitLeft

      public void setMarginUnitLeft(byte unit)

      Sets left margin unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setMarginUnitRight

      public void setMarginUnitRight(byte unit)

      Sets right margin unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setMarginUnitTop

      public void setMarginUnitTop(byte unit)

      Sets top margin unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • setMarginUnitBottom

      public void setMarginUnitBottom(byte unit)

      Sets bottom margin unit.

      Parameters
      • unit: @param unit One of #UNIT_TYPE_PIXELS, #UNIT_TYPE_DIPS, #UNIT_TYPE_SCREEN_PERCENTAGE, #UNIT_TYPE_VW, #UNIT_TYPE_VH, #UNIT_TYPE_VMIN, #UNIT_TYPE_VMAX, #UNIT_TYPE_REM.
      Since

      7.0

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object