JavaTM Platform
Standard Ed. 6

javax.swing.plaf.basic
クラス BasicSliderUI

java.lang.Object
  上位を拡張 javax.swing.plaf.ComponentUI
      上位を拡張 javax.swing.plaf.SliderUI
          上位を拡張 javax.swing.plaf.basic.BasicSliderUI
直系の既知のサブクラス:
MetalSliderUI

public class BasicSliderUI
extends SliderUI

SliderUI の基本 Look & Feel による実装です。


入れ子のクラスの概要
 class BasicSliderUI.ActionScroller
          ドキュメントから削除されたこのクラスは、Java 2 プラットフォーム 1.3 では使用しません。
 class BasicSliderUI.ChangeHandler
          データモデルのリスナーです。
 class BasicSliderUI.ComponentHandler
          サイズ変更イベントのリスナーです。
 class BasicSliderUI.FocusHandler
          フォーカス変更のリスナーです。
 class BasicSliderUI.PropertyChangeHandler
           
 class BasicSliderUI.ScrollListener
          スクロールイベントリスナーです。
 class BasicSliderUI.TrackListener
          マウスの動きを追跡します。
 
フィールドの概要
protected  ChangeListener changeListener
           
protected  ComponentListener componentListener
           
protected  Rectangle contentRect
           
protected  Insets focusInsets
           
protected  FocusListener focusListener
           
protected  Rectangle focusRect
           
protected  Insets insetCache
           
protected  Rectangle labelRect
           
protected  boolean leftToRightCache
           
static int MAX_SCROLL
           
static int MIN_SCROLL
           
static int NEGATIVE_SCROLL
           
static int POSITIVE_SCROLL
           
protected  PropertyChangeListener propertyChangeListener
           
protected  BasicSliderUI.ScrollListener scrollListener
           
protected  Timer scrollTimer
           
protected  JSlider slider
           
protected  Rectangle thumbRect
           
protected  Rectangle tickRect
           
protected  int trackBuffer
           
protected  BasicSliderUI.TrackListener trackListener
           
protected  Rectangle trackRect
           
 
コンストラクタの概要
BasicSliderUI(JSlider b)
           
 
メソッドの概要
protected  void calculateContentRect()
           
protected  void calculateFocusRect()
           
protected  void calculateGeometry()
           
protected  void calculateLabelRect()
           
protected  void calculateThumbLocation()
           
protected  void calculateThumbSize()
           
protected  void calculateTickRect()
           
protected  void calculateTrackBuffer()
           
protected  void calculateTrackRect()
           
protected  ChangeListener createChangeListener(JSlider slider)
           
protected  ComponentListener createComponentListener(JSlider slider)
           
protected  FocusListener createFocusListener(JSlider slider)
           
protected  PropertyChangeListener createPropertyChangeListener(JSlider slider)
           
protected  BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
           
protected  BasicSliderUI.TrackListener createTrackListener(JSlider slider)
           
static ComponentUI createUI(JComponent b)
           
protected  boolean drawInverted()
           
 int getBaseline(JComponent c, int width, int height)
          ベースラインを返します。
 Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
          コンポーネントのサイズが変化するにつれてベースラインが変化する方法の列挙を返します。
protected  Color getFocusColor()
           
protected  int getHeightOfHighValueLabel()
           
protected  int getHeightOfLowValueLabel()
           
protected  int getHeightOfTallestLabel()
           
protected  Integer getHighestValue()
          ラベルテーブルにエントリを持つ最大の値を返します。
protected  Component getHighestValueLabel()
          ラベルテーブルの最小のスライダ値に対応するラベルを返します。
protected  Color getHighlightColor()
           
protected  Integer getLowestValue()
          ラベルテーブルにエントリを持つ最小の値を返します。
protected  Component getLowestValueLabel()
          ラベルテーブルの最大のスライダ値に対応するラベルを返します。
 Dimension getMaximumSize(JComponent c)
          Look & Feel に適した、指定されたコンポーネントの最大サイズを返します。
 Dimension getMinimumHorizontalSize()
           
 Dimension getMinimumSize(JComponent c)
          Look & Feel に適した、指定されたコンポーネントの最小サイズを返します。
 Dimension getMinimumVerticalSize()
           
 Dimension getPreferredHorizontalSize()
           
 Dimension getPreferredSize(JComponent c)
          Look & Feel に適した、指定されたコンポーネントの適切なサイズを返します。
 Dimension getPreferredVerticalSize()
           
protected  Color getShadowColor()
           
protected  Dimension getThumbSize()
           
protected  int getTickLength()
          水平スライダの目盛り領域の高さおよび垂直スライダの目盛り領域の幅を返します。
protected  int getWidthOfHighValueLabel()
           
protected  int getWidthOfLowValueLabel()
           
protected  int getWidthOfWidestLabel()
           
protected  void installDefaults(JSlider slider)
           
protected  void installKeyboardActions(JSlider slider)
           
protected  void installListeners(JSlider slider)
           
 void installUI(JComponent c)
          Look & Feel に適した、指定されたコンポーネントを構成します。
protected  boolean isDragging()
          ユーザーがスライダをドラッグしている場合は true を返します。
protected  boolean labelsHaveSameBaselines()
          ラベルテーブルのすべてのラベルのベースラインが同じである場合に true を返します。
 void paint(Graphics g, JComponent c)
          Look &Feel に適した、指定されたコンポーネントをペイントします。
 void paintFocus(Graphics g)
           
protected  void paintHorizontalLabel(Graphics g, int value, Component label)
          ラベルテーブルの各ラベルに対して呼び出されます。
 void paintLabels(Graphics g)
           
protected  void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
           
protected  void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
           
protected  void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
           
protected  void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
           
 void paintThumb(Graphics g)
           
 void paintTicks(Graphics g)
           
 void paintTrack(Graphics g)
           
protected  void paintVerticalLabel(Graphics g, int value, Component label)
          ラベルテーブルの各ラベルに対して呼び出されます。
protected  void recalculateIfInsetsChanged()
           
protected  void recalculateIfOrientationChanged()
           
 void scrollByBlock(int direction)
           
 void scrollByUnit(int direction)
           
protected  void scrollDueToClickInTrack(int dir)
          サムではなくトラックで mousePressed が検出されたときに呼び出されます。
 void setThumbLocation(int x, int y)
           
protected  void uninstallKeyboardActions(JSlider slider)
           
protected  void uninstallListeners(JSlider slider)
           
 void uninstallUI(JComponent c)
          installUI 時に、指定されたコンポーネントで構成された内容を取り消します。
 int valueForXPosition(int xPos)
          x 位置を示す値を返します。
 int valueForYPosition(int yPos)
          y 位置を示す値を返します。
protected  int xPositionForValue(int value)
           
protected  int yPositionForValue(int value)
           
protected  int yPositionForValue(int value, int trackY, int trackHeight)
          指定された値の y の位置を返します。
 
クラス javax.swing.plaf.ComponentUI から継承されたメソッド
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

POSITIVE_SCROLL

public static final int POSITIVE_SCROLL
関連項目:
定数フィールド値

NEGATIVE_SCROLL

public static final int NEGATIVE_SCROLL
関連項目:
定数フィールド値

MIN_SCROLL

public static final int MIN_SCROLL
関連項目:
定数フィールド値

MAX_SCROLL

public static final int MAX_SCROLL
関連項目:
定数フィールド値

scrollTimer

protected Timer scrollTimer

slider

protected JSlider slider

focusInsets

protected Insets focusInsets

insetCache

protected Insets insetCache

leftToRightCache

protected boolean leftToRightCache

focusRect

protected Rectangle focusRect

contentRect

protected Rectangle contentRect

labelRect

protected Rectangle labelRect

tickRect

protected Rectangle tickRect

trackRect

protected Rectangle trackRect

thumbRect

protected Rectangle thumbRect

trackBuffer

protected int trackBuffer

trackListener

protected BasicSliderUI.TrackListener trackListener

changeListener

protected ChangeListener changeListener

componentListener

protected ComponentListener componentListener

focusListener

protected FocusListener focusListener

scrollListener

protected BasicSliderUI.ScrollListener scrollListener

propertyChangeListener

protected PropertyChangeListener propertyChangeListener
コンストラクタの詳細

BasicSliderUI

public BasicSliderUI(JSlider b)
メソッドの詳細

getShadowColor

protected Color getShadowColor()

getHighlightColor

protected Color getHighlightColor()

getFocusColor

protected Color getFocusColor()

isDragging

protected boolean isDragging()
ユーザーがスライダをドラッグしている場合は true を返します。

戻り値:
ユーザーがスライダをドラッグしている場合は true
導入されたバージョン:
1.5

createUI

public static ComponentUI createUI(JComponent b)

installUI

public void installUI(JComponent c)
クラス ComponentUI の記述:
Look & Feel に適した、指定されたコンポーネントを構成します。このメソッドは、ComponentUI インスタンスが、指定されたコンポーネントの UI 委譲としてインストールされているときに呼び出されます。このメソッドは、次を含む Look & Feel 用のコンポーネントを完全に構成する必要があります。
  1. カラー、フォント、ボーダー、アイコン、不透明さなどすべてのデフォルトプロパティーの値をコンポーネントにインストールする。可能な場合は、クライアントプログラムによって初期化されたプロパティーの値をオーバーライドしてはならない
  2. 必要に応じて、コンポーネントに LayoutManager をインストールする
  3. 必要なサブコンポーネントを、コンポーネントに作成または追加する
  4. イベントリスナーを、コンポーネントに作成またはインストールする
  5. コンポーネントのプロパティーの変更を適切に検出し、応答するために、PropertyChangeListener をコンポーネントに作成またはインストールする
  6. キーボード UI (ニーモニック、トラバーサルなど) を、コンポーネントにインストールする
  7. 適切なインスタンスのデータを初期化する

オーバーライド:
クラス ComponentUI 内の installUI
パラメータ:
c - UI 委譲がインストールされているコンポーネント
関連項目:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
クラス ComponentUI の記述:
installUI 時に、指定されたコンポーネントで構成された内容を取り消します。このメソッドは、指定されたコンポーネントの UI 委譲としての UIComponent インスタンスが削除されているときに呼び出されます。このメソッドは、installUI によって実行された構成を元に戻す必要があります。この場合、JComponent インスタンスをクリーンな状態 (余分なリスナーや、Look & Feel 固有のプロパティーオブジェクトが残らないように) にするよう十分注意してください。手順には次のものがあります。
  1. UI として設定されたすべてのボーダーを、コンポーネントから削除する
  2. UI として設定されたすべてのレイアウトマネージャーを、コンポーネントから削除する
  3. UI として追加されたすべてのサブコンポーネントを、コンポーネントから削除する
  4. UI として追加されたすべてのイベント/リスナーを、コンポーネントから削除する
  5. UI としてインストールされたすべてのキーボード UI を、コンポーネントから削除する
  6. GC 用に割り当てられたすべてのインスタンスのデータオブジェクトを無効にする

オーバーライド:
クラス ComponentUI 内の uninstallUI
パラメータ:
c - この UI 委譲を削除するコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
関連項目:
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

installDefaults

protected void installDefaults(JSlider slider)

createTrackListener

protected BasicSliderUI.TrackListener createTrackListener(JSlider slider)

createChangeListener

protected ChangeListener createChangeListener(JSlider slider)

createComponentListener

protected ComponentListener createComponentListener(JSlider slider)

createFocusListener

protected FocusListener createFocusListener(JSlider slider)

createScrollListener

protected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JSlider slider)

installListeners

protected void installListeners(JSlider slider)

uninstallListeners

protected void uninstallListeners(JSlider slider)

installKeyboardActions

protected void installKeyboardActions(JSlider slider)

uninstallKeyboardActions

protected void uninstallKeyboardActions(JSlider slider)

getBaseline

public int getBaseline(JComponent c,
                       int width,
                       int height)
ベースラインを返します。

オーバーライド:
クラス ComponentUI 内の getBaseline
パラメータ:
c - 要求される JComponent ベースライン
width - ベースラインを取得する幅
height - ベースラインを取得する高さ
戻り値:
ベースラインまたは 0 より小さい値 (適切なベースラインがないことを示す)
例外:
NullPointerException - cnull の場合
IllegalArgumentException - 幅または高さが 0 より小さい場合
導入されたバージョン:
1.6
関連項目:
JComponent.getBaseline(int, int)

getBaselineResizeBehavior

public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
コンポーネントのサイズが変化するにつれてベースラインが変化する方法の列挙を返します。

オーバーライド:
クラス ComponentUI 内の getBaselineResizeBehavior
パラメータ:
c - ベースラインのサイズ変更の動作を返す JComponent
戻り値:
コンポーネントのサイズが変化するにつれてベースラインが変化する方法の列挙
例外:
NullPointerException - cnull の場合
導入されたバージョン:
1.6
関連項目:
JComponent.getBaseline(int, int)

labelsHaveSameBaselines

protected boolean labelsHaveSameBaselines()
ラベルテーブルのすべてのラベルのベースラインが同じである場合に true を返します。

戻り値:
ラベルテーブルのすべてのラベルのベースラインが同じである場合は true
導入されたバージョン:
1.6

getPreferredHorizontalSize

public Dimension getPreferredHorizontalSize()

getPreferredVerticalSize

public Dimension getPreferredVerticalSize()

getMinimumHorizontalSize

public Dimension getMinimumHorizontalSize()

getMinimumVerticalSize

public Dimension getMinimumVerticalSize()

getPreferredSize

public Dimension getPreferredSize(JComponent c)
クラス ComponentUI の記述:
Look & Feel に適した、指定されたコンポーネントの適切なサイズを返します。null が返される場合、適切なサイズは代わりにコンポーネントのレイアウトマネージャーによって計算されます (これは、特定のレイアウトマネージャーをインストールしてあるコンポーネントの場合に推奨する方法です)。このメソッドのデフォルト実装は null を返します。

オーバーライド:
クラス ComponentUI 内の getPreferredSize
パラメータ:
c - 適切なサイズを照会されるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
関連項目:
JComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)

getMinimumSize

public Dimension getMinimumSize(JComponent c)
クラス ComponentUI の記述:
Look & Feel に適した、指定されたコンポーネントの最小サイズを返します。null が返される場合、最小サイズは代わりにコンポーネントのレイアウトマネージャーによって計算されます (これは、特定のレイアウトマネージャーをインストールしてあるコンポーネントの場合に推奨する方法です)。このメソッドのデフォルト実装は getPreferredSize を呼び出して、その値を返します。

オーバーライド:
クラス ComponentUI 内の getMinimumSize
パラメータ:
c - 最小サイズを照会されるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
戻り値:
Dimension オブジェクト、または null
関連項目:
JComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)

getMaximumSize

public Dimension getMaximumSize(JComponent c)
クラス ComponentUI の記述:
Look & Feel に適した、指定されたコンポーネントの最大サイズを返します。null が返される場合、最大サイズは代わりにコンポーネントのレイアウトマネージャーによって計算されます (これは、特定のレイアウトマネージャーをインストールしてあるコンポーネントの場合に推奨する方法です)。このメソッドのデフォルト実装は getPreferredSize を呼び出して、その値を返します。

オーバーライド:
クラス ComponentUI 内の getMaximumSize
パラメータ:
c - 最大サイズを照会されるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
戻り値:
Dimension オブジェクト、または null
関連項目:
JComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)

calculateGeometry

protected void calculateGeometry()

calculateFocusRect

protected void calculateFocusRect()

calculateThumbSize

protected void calculateThumbSize()

calculateContentRect

protected void calculateContentRect()

calculateThumbLocation

protected void calculateThumbLocation()

calculateTrackBuffer

protected void calculateTrackBuffer()

calculateTrackRect

protected void calculateTrackRect()

getTickLength

protected int getTickLength()
水平スライダの目盛り領域の高さおよび垂直スライダの目盛り領域の幅を返します。BasicSliderUI は、このメソッドの戻り値を使って目盛り領域の矩形を決定します。目盛りの長さを長くするには、この値を必要な値より大きくし、paintTicks() の辺の長さに関係なく目盛りをペイントします。


calculateTickRect

protected void calculateTickRect()

calculateLabelRect

protected void calculateLabelRect()

getThumbSize

protected Dimension getThumbSize()

getWidthOfWidestLabel

protected int getWidthOfWidestLabel()

getHeightOfTallestLabel

protected int getHeightOfTallestLabel()

getWidthOfHighValueLabel

protected int getWidthOfHighValueLabel()

getWidthOfLowValueLabel

protected int getWidthOfLowValueLabel()

getHeightOfHighValueLabel

protected int getHeightOfHighValueLabel()

getHeightOfLowValueLabel

protected int getHeightOfLowValueLabel()

drawInverted

protected boolean drawInverted()

getHighestValue

protected Integer getHighestValue()
ラベルテーブルにエントリを持つ最大の値を返します。

戻り値:
ラベルテーブルにエントリを持つ最大の値、または null
導入されたバージョン:
1.6

getLowestValue

protected Integer getLowestValue()
ラベルテーブルにエントリを持つ最小の値を返します。

戻り値:
ラベルテーブルにエントリを持つ最小の値、または null
導入されたバージョン:
1.6

getLowestValueLabel

protected Component getLowestValueLabel()
ラベルテーブルの最大のスライダ値に対応するラベルを返します。

関連項目:
JSlider.setLabelTable(java.util.Dictionary)

getHighestValueLabel

protected Component getHighestValueLabel()
ラベルテーブルの最小のスライダ値に対応するラベルを返します。

関連項目:
JSlider.setLabelTable(java.util.Dictionary)

paint

public void paint(Graphics g,
                  JComponent c)
クラス ComponentUI の記述:
Look &Feel に適した、指定されたコンポーネントをペイントします。このメソッドは ComponentUI.update メソッドから、指定されたコンポーネントがペイントされるときに呼び出されます。サブクラスは、このメソッドをオーバーライドして、指定された Graphics オブジェクトを使ってコンポーネントの内容を描画する必要があります。

オーバーライド:
クラス ComponentUI 内の paint
パラメータ:
g - ペイント対象の Graphics コンテキスト
c - ペイントされるコンポーネント。 この引数は通常無視されるが、 UI オブジェクトに状態がなく、複数のコンポーネントに共有されている場合は 使用されることがある
関連項目:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

recalculateIfInsetsChanged

protected void recalculateIfInsetsChanged()

recalculateIfOrientationChanged

protected void recalculateIfOrientationChanged()

paintFocus

public void paintFocus(Graphics g)

paintTrack

public void paintTrack(Graphics g)

paintTicks

public void paintTicks(Graphics g)

paintMinorTickForHorizSlider

protected void paintMinorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)

paintMajorTickForHorizSlider

protected void paintMajorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)

paintMinorTickForVertSlider

protected void paintMinorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)

paintMajorTickForVertSlider

protected void paintMajorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)

paintLabels

public void paintLabels(Graphics g)

paintHorizontalLabel

protected void paintHorizontalLabel(Graphics g,
                                    int value,
                                    Component label)
ラベルテーブルの各ラベルに対して呼び出されます。水平スライダのラベルを描画するために使われます。グラフィックスはすでに labelRect.y に変換されています。

関連項目:
JSlider.setLabelTable(java.util.Dictionary)

paintVerticalLabel

protected void paintVerticalLabel(Graphics g,
                                  int value,
                                  Component label)
ラベルテーブルの各ラベルに対して呼び出されます。垂直スライダのラベルを描画するために使われます。グラフィックスはすでに labelRect.x に変換されています。

関連項目:
JSlider.setLabelTable(java.util.Dictionary)

paintThumb

public void paintThumb(Graphics g)

setThumbLocation

public void setThumbLocation(int x,
                             int y)

scrollByBlock

public void scrollByBlock(int direction)

scrollByUnit

public void scrollByUnit(int direction)

scrollDueToClickInTrack

protected void scrollDueToClickInTrack(int dir)
サムではなくトラックで mousePressed が検出されたときに呼び出されます。デフォルトの動作では、ブロック単位でスクロールします。このメソッドをオーバーライドすると、スクロールを停止させたり、新しく動作を追加したりすることができます。


xPositionForValue

protected int xPositionForValue(int value)

yPositionForValue

protected int yPositionForValue(int value)

yPositionForValue

protected int yPositionForValue(int value,
                                int trackY,
                                int trackHeight)
指定された値の y の位置を返します。引数のチェックは行われません。特に、trackHeight が負の数だった場合の結果は保証されません。

パラメータ:
value - 位置を取得するスライダ値
trackY - トラックの y 原点
trackHeight - トラックの高さ
導入されたバージョン:
1.6

valueForYPosition

public int valueForYPosition(int yPos)
y 位置を示す値を返します。yPos がトラックの上端または下端を越えている場合、スライダが反転しているかどうかに応じて、スライダの最小値または最大値に設定されます。


valueForXPosition

public int valueForXPosition(int xPos)
x 位置を示す値を返します。xPos がトラックの左端または右端を越えている場合、スライダが反転しているかどうかに応じて、スライダの最小値または最大値に設定されます。


JavaTM Platform
Standard Ed. 6

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

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