javax.swing.plaf.synth
Class ColorType

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.plaf.synth.ColorType

public class ColorType
extends Object sample code for java.lang.Object definition code for java.lang.Object

A typesafe enumeration of colors that can be fetched from a style.

Each SynthStyle has a set of ColorTypes that are accessed by way of the SynthStyle.getColor(SynthContext, ColorType) sample code for javax.swing.plaf.synth.SynthStyle.getColor(javax.swing.plaf.synth.SynthContext, javax.swing.plaf.synth.ColorType) definition code for javax.swing.plaf.synth.SynthStyle.getColor(javax.swing.plaf.synth.SynthContext, javax.swing.plaf.synth.ColorType) method. SynthStyle's installDefaults will install the FOREGROUND color as the foreground of the Component, and the BACKGROUND color to the background of the component (assuming that you have not explicitly specified a foreground and background color). Some components support more color based properties, for example JList has the property selectionForeground which will be mapped to FOREGROUND with a component state of SynthConstants.SELECTED.

The following example shows a custom SynthStyle that returns a red Color for the DISABLED state, otherwise a black color.

 class MyStyle extends SynthStyle {
     private Color disabledColor = new ColorUIResource(Color.RED);
     private Color color = new ColorUIResource(Color.BLACK);
     protected Color getColorForState(SynthContext context, ColorType type){
         if (context.getComponentState() == SynthConstants.DISABLED) {
             return disabledColor;
         }
         return color;
     }
 }
 

Since:
1.5

Field Summary
static ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType BACKGROUND sample code for javax.swing.plaf.synth.ColorType.BACKGROUND definition code for javax.swing.plaf.synth.ColorType.BACKGROUND
          ColorType for the background of a region.
static ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType FOCUS sample code for javax.swing.plaf.synth.ColorType.FOCUS definition code for javax.swing.plaf.synth.ColorType.FOCUS
          ColorType for the focus.
static ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType FOREGROUND sample code for javax.swing.plaf.synth.ColorType.FOREGROUND definition code for javax.swing.plaf.synth.ColorType.FOREGROUND
          ColorType for the foreground of a region.
static int MAX_COUNT sample code for javax.swing.plaf.synth.ColorType.MAX_COUNT definition code for javax.swing.plaf.synth.ColorType.MAX_COUNT
          Maximum number of ColorTypes.
static ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType TEXT_BACKGROUND sample code for javax.swing.plaf.synth.ColorType.TEXT_BACKGROUND definition code for javax.swing.plaf.synth.ColorType.TEXT_BACKGROUND
          ColorType for the background of a region.
static ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType TEXT_FOREGROUND sample code for javax.swing.plaf.synth.ColorType.TEXT_FOREGROUND definition code for javax.swing.plaf.synth.ColorType.TEXT_FOREGROUND
          ColorType for the foreground of a region.
 
Constructor Summary
protected ColorType sample code for javax.swing.plaf.synth.ColorType.ColorType(java.lang.String) definition code for javax.swing.plaf.synth.ColorType.ColorType(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  description)
          Creates a new ColorType with the specified description.
 
Method Summary
 int getID sample code for javax.swing.plaf.synth.ColorType.getID() definition code for javax.swing.plaf.synth.ColorType.getID() ()
          Returns a unique id, as an integer, for this ColorType.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.swing.plaf.synth.ColorType.toString() definition code for javax.swing.plaf.synth.ColorType.toString() ()
          Returns the textual description of this ColorType.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

FOREGROUND sample code for javax.swing.plaf.synth.ColorType.FOREGROUND

public static final ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType  FOREGROUND
ColorType for the foreground of a region.


BACKGROUND sample code for javax.swing.plaf.synth.ColorType.BACKGROUND

public static final ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType  BACKGROUND
ColorType for the background of a region.


TEXT_FOREGROUND sample code for javax.swing.plaf.synth.ColorType.TEXT_FOREGROUND

public static final ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType  TEXT_FOREGROUND
ColorType for the foreground of a region.


TEXT_BACKGROUND sample code for javax.swing.plaf.synth.ColorType.TEXT_BACKGROUND

public static final ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType  TEXT_BACKGROUND
ColorType for the background of a region.


FOCUS sample code for javax.swing.plaf.synth.ColorType.FOCUS

public static final ColorType sample code for javax.swing.plaf.synth.ColorType definition code for javax.swing.plaf.synth.ColorType  FOCUS
ColorType for the focus.


MAX_COUNT sample code for javax.swing.plaf.synth.ColorType.MAX_COUNT

public static final int MAX_COUNT
Maximum number of ColorTypes.

Constructor Detail

ColorType sample code for javax.swing.plaf.synth.ColorType(java.lang.String) definition code for javax.swing.plaf.synth.ColorType(java.lang.String)

protected ColorType(String sample code for java.lang.String definition code for java.lang.String  description)
Creates a new ColorType with the specified description.

Parameters:
description - String description of the ColorType.
Method Detail

getID sample code for javax.swing.plaf.synth.ColorType.getID() definition code for javax.swing.plaf.synth.ColorType.getID()

public final int getID()
Returns a unique id, as an integer, for this ColorType.

Returns:
a unique id, as an integer, for this ColorType.

toString sample code for javax.swing.plaf.synth.ColorType.toString() definition code for javax.swing.plaf.synth.ColorType.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns the textual description of this ColorType.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
description of the string.