Class ColorUIResource

java.lang.Object
java.awt.Color
javax.swing.plaf.ColorUIResource
All Implemented Interfaces:
Paint, Transparency, Serializable, UIResource

public class ColorUIResource extends Color implements UIResource
A subclass of Color that implements UIResource. UI classes that create colors should use this class.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see XMLEncoder.

See Also:
  • Field Summary

    Fields declared in class Color

    black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOW
    Modifier and Type
    Field
    Description
    static final Color
    The color black.
    static final Color
    The color black.
    static final Color
    The color blue.
    static final Color
    The color blue.
    static final Color
    The color cyan.
    static final Color
    The color cyan.
    static final Color
    The color dark gray.
    static final Color
    The color dark gray.
    static final Color
    The color gray.
    static final Color
    The color gray.
    static final Color
    The color green.
    static final Color
    The color green.
    static final Color
    The color light gray.
    static final Color
    The color light gray.
    static final Color
    The color magenta.
    static final Color
    The color magenta.
    static final Color
    The color orange.
    static final Color
    The color orange.
    static final Color
    The color pink.
    static final Color
    The color pink.
    static final Color
    The color red.
    static final Color
    The color red.
    static final Color
    The color white.
    static final Color
    The color white.
    static final Color
    The color yellow.
    static final Color
    The color yellow.

    Fields declared in interface Transparency

    BITMASK, OPAQUE, TRANSLUCENT
    Modifier and Type
    Field
    Description
    static final int
    Represents image data that is guaranteed to be either completely opaque, with an alpha value of 1.0, or completely transparent, with an alpha value of 0.0.
    static final int
    Represents image data that is guaranteed to be completely opaque, meaning that all pixels have an alpha value of 1.0.
    static final int
    Represents image data that contains or might contain arbitrary alpha values between and including 0.0 and 1.0.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ColorUIResource(float r, float g, float b)
    Constructs a ColorUIResource.
    ColorUIResource(int rgb)
    Constructs a ColorUIResource.
    ColorUIResource(int r, int g, int b)
    Constructs a ColorUIResource.
    Constructs a ColorUIResource.
  • Method Summary

    Methods declared in class Color

    brighter, createContext, darker, decode, equals, getAlpha, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGB, getRGBColorComponents, getRGBComponents, getTransparency, hashCode, HSBtoRGB, RGBtoHSB, toString
    Modifier and Type
    Method
    Description
    Creates a new Color that is a brighter version of this Color.
    Creates and returns a PaintContext used to generate a solid color field pattern.
    Creates a new Color that is a darker version of this Color.
    static Color
    Converts a String to an integer and returns the specified opaque Color.
    boolean
    Determines whether another object is equal to this Color.
    int
    Returns the alpha component in the range 0-255.
    int
    Returns the blue component in the range 0-255 in the default sRGB space.
    static Color
    Finds a color in the system properties.
    static Color
    getColor(String nm, int v)
    Finds a color in the system properties.
    static Color
    Finds a color in the system properties.
    float[]
    getColorComponents(float[] compArray)
    Returns a float array containing only the color components of the Color, in the ColorSpace of the Color.
    float[]
    getColorComponents(ColorSpace cspace, float[] compArray)
    Returns a float array containing only the color components of the Color in the ColorSpace specified by the cspace parameter.
    Returns the ColorSpace of this Color.
    float[]
    getComponents(float[] compArray)
    Returns a float array containing the color and alpha components of the Color, in the ColorSpace of the Color.
    float[]
    getComponents(ColorSpace cspace, float[] compArray)
    Returns a float array containing the color and alpha components of the Color, in the ColorSpace specified by the cspace parameter.
    int
    Returns the green component in the range 0-255 in the default sRGB space.
    static Color
    getHSBColor(float h, float s, float b)
    Creates a Color object based on the specified values for the HSB color model.
    int
    Returns the red component in the range 0-255 in the default sRGB space.
    int
    Returns the RGB value representing the color in the default sRGB ColorModel, consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
    float[]
    getRGBColorComponents(float[] compArray)
    Returns a float array containing only the color components of the Color, in the default sRGB color space.
    float[]
    getRGBComponents(float[] compArray)
    Returns a float array containing the color and alpha components of the Color, as represented in the default sRGB color space.
    int
    Returns the transparency mode for this Color.
    int
    Computes the hash code for this Color.
    static int
    HSBtoRGB(float hue, float saturation, float brightness)
    Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.
    static float[]
    RGBtoHSB(int r, int g, int b, float[] hsbvals)
    Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.
    Returns a string representation of this Color.

    Methods declared in class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Creates and returns a copy of this object.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Finalization is deprecated and subject to removal in a future release.
    final Class<?>
    Returns the runtime class of this Object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    final void
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
    final void
    wait(long timeoutMillis)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
    final void
    wait(long timeoutMillis, int nanos)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  • Constructor Details

    • ColorUIResource

      @ConstructorProperties({"red","green","blue"}) public ColorUIResource(int r, int g, int b)
      Constructs a ColorUIResource.
      Parameters:
      r - the red component
      g - the green component
      b - the blue component
    • ColorUIResource

      public ColorUIResource(int rgb)
      Constructs a ColorUIResource.
      Parameters:
      rgb - the combined RGB components
    • ColorUIResource

      public ColorUIResource(float r, float g, float b)
      Constructs a ColorUIResource.
      Parameters:
      r - the red component
      g - the green component
      b - the blue component
    • ColorUIResource

      public ColorUIResource(Color c)
      Constructs a ColorUIResource.
      Parameters:
      c - the color