JavaTM Platform
Standard Ed. 6

javax.swing.plaf.synth
クラス ColorType

java.lang.Object
  上位を拡張 javax.swing.plaf.synth.ColorType

public class ColorType
extends Object

スタイルから取得できる型保証された色の列挙です。

SynthStyle には、SynthStyle.getColor(SynthContext, ColorType) メソッドを介してアクセスできる 1 組の ColorType があります。SynthStyleinstallDefaults は、FOREGROUND カラーをコンポーネントのフォアグラウンドとしてインストールし、BACKGROUND カラーをコンポーネントのバックグラウンドとしてインストールします (フォアグラウンドカラーやバックグラウンドカラーを明示的に指定しない場合)。コンポーネントの中には、さらにいくつかの色に基づくプロパティーをサポートしているものもあります。 たとえば、JList には SynthConstants.SELECTED のコンポーネント状態に合わせて FOREGROUND にマップされる selectionForeground プロパティーがあります。

次の例は、DISABLED 状態の場合は赤い色を返し、それ以外の場合は黒い色を返すカスタムの SynthStyle を示しています。

 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;
     }
 }
 

導入されたバージョン:
1.5

フィールドの概要
static ColorType BACKGROUND
          領域のバックグラウンド用の ColorType です。
static ColorType FOCUS
          フォーカス用の ColorType です。
static ColorType FOREGROUND
          領域のフォアグラウンド用の ColorType です。
static int MAX_COUNT
          ColorType の最大数です。
static ColorType TEXT_BACKGROUND
          領域のバックグラウンド用の ColorType です。
static ColorType TEXT_FOREGROUND
          領域のフォアグラウンド用の ColorType です。
 
コンストラクタの概要
protected ColorType(String description)
          指定された説明を使って新しい ColorType を作成します。
 
メソッドの概要
 int getID()
          この ColorType の一意の ID を整数値として返します。
 String toString()
          この ColorType のテキスト形式の説明を返します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

FOREGROUND

public static final ColorType FOREGROUND
領域のフォアグラウンド用の ColorType です。


BACKGROUND

public static final ColorType BACKGROUND
領域のバックグラウンド用の ColorType です。


TEXT_FOREGROUND

public static final ColorType TEXT_FOREGROUND
領域のフォアグラウンド用の ColorType です。


TEXT_BACKGROUND

public static final ColorType TEXT_BACKGROUND
領域のバックグラウンド用の ColorType です。


FOCUS

public static final ColorType FOCUS
フォーカス用の ColorType です。


MAX_COUNT

public static final int MAX_COUNT
ColorType の最大数です。

コンストラクタの詳細

ColorType

protected ColorType(String description)
指定された説明を使って新しい ColorType を作成します。

パラメータ:
description - ColorType の説明を表す String
メソッドの詳細

getID

public final int getID()
この ColorType の一意の ID を整数値として返します。

戻り値:
この ColorType の一意の ID (整数値)

toString

public String toString()
この ColorType のテキスト形式の説明を返します。これは、ColorType の作成時に使用した値と同じです。

オーバーライド:
クラス Object 内の toString
戻り値:
この文字列の説明

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。