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
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • 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