|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--javax.swing.SwingUtilities
Swing のユーティリティメソッドのコレクションです。
メソッドの概要 | |
static Rectangle[] |
computeDifference(Rectangle rectA,
Rectangle rectB)
rectB とオーバーラップしない rectA 内の領域を表現する矩形の配列を返すために使われます。 |
static Rectangle |
computeIntersection(int x,
int y,
int width,
int height,
Rectangle dest)
新しい矩形 dest を割り当てずに、2 つの矩形の共通部分を計算するのに便利です。 |
static int |
computeStringWidth(FontMetrics fm,
String str)
指定されたメトリックス (サイズ) を持つフォントを使って文字列の幅を計算します。 |
static Rectangle |
computeUnion(int x,
int y,
int width,
int height,
Rectangle dest)
新しい矩形 dest を割り当てずに、2 つの矩形の和集合を計算するのに便利です。 |
static MouseEvent |
convertMouseEvent(Component source,
MouseEvent sourceEvent,
Component destination)
その x と y メンバが destination の座標系に変換済みの場合を除いて、sourceEvent と同じような MouseEvent を返します。 |
static Point |
convertPoint(Component source,
int x,
int y,
Component destination)
source 座標系の点 (x,y) を destination 座標系に変換します。 |
static Point |
convertPoint(Component source,
Point aPoint,
Component destination)
source 座標系の aPoint を destination 座標系に変換します。 |
static void |
convertPointFromScreen(Point p,
Component c)
ポイントを画面座標からコンポーネントの座標系に変換します。 |
static void |
convertPointToScreen(Point p,
Component c)
ポイントをコンポーネントの座標系から画面座標に変換します。 |
static Rectangle |
convertRectangle(Component source,
Rectangle aRectangle,
Component destination)
source 座標系の aRectangle を destination 座標系に変換します。 |
static Component |
findFocusOwner(Component c)
フォーカスを持つ子コンポーネントがある場合はそれを返します。 |
static Accessible |
getAccessibleAt(Component c,
Point p)
ローカル座標の Point にユーザ補助機能を実装する子が保持されている場合はそれを返します。 |
static Accessible |
getAccessibleChild(Component c,
int i)
オブジェクトのユーザ補助機能を実装する i 番目の子を返します。 |
static int |
getAccessibleChildrenCount(Component c)
オブジェクト内のユーザ補助機能を実装する子の数を返します。 |
static int |
getAccessibleIndexInParent(Component c)
ユーザ補助機能を実装する親でのこのオブジェクトのインデックスを取得します。 |
static AccessibleStateSet |
getAccessibleStateSet(Component c)
このオブジェクトの状態を取得します。 |
static Container |
getAncestorNamed(String name,
Component comp)
コンポーネント階層の上記の comp を検索するための簡易メソッドであり、見つかった name の最初のオブジェクトを返します。 |
static Container |
getAncestorOfClass(Class c,
Component comp)
コンポーネント階層の上位の comp を検索するための簡易メソッドであり、見つかった c クラスの最初のオブジェクトを返します。 |
static Component |
getDeepestComponentAt(Component parent,
int x,
int y)
位置 x 、y を内包する parent を親として持つ、最下位の可視 Component を返します。 |
static Rectangle |
getLocalBounds(Component aComponent)
aComponent コンポーネントの矩形 (0,0,bounds.width,bounds.height) を返します。 |
static Component |
getRoot(Component c)
現在のコンポーネントツリーのルートコンポーネントを返します。 |
static JRootPane |
getRootPane(Component c)
c が下位 JRootPane オブジェクトの場合は、その上位 JRootPane オブジェクトを返します。 |
static void |
invokeAndWait(Runnable doRun)
doRun.run() を、AWT イベントディスパッチ元イベントで非同期的に実行させます。 |
static void |
invokeLater(Runnable doRun)
doRun.run() を、AWT イベントディスパッチ元イベントで非同期的に実行させます。 |
static boolean |
isDescendingFrom(Component a,
Component b)
コンポーネント a がコンポーネント b から派生する場合に true を返します。 |
static boolean |
isEventDispatchThread()
現在のスレッドが AWT イベントディスパッチ元スレッドの場合に true を返します。 |
static boolean |
isLeftMouseButton(MouseEvent anEvent)
マウスイベントが左マウスボタンを示す場合に true を返します。 |
static boolean |
isMiddleMouseButton(MouseEvent anEvent)
マウスイベントが中央のマウスボタンを示す場合に true を返します。 |
static boolean |
isRectangleContainingRectangle(Rectangle a,
Rectangle b)
a が b を保持する場合に true を返します。 |
static boolean |
isRightMouseButton(MouseEvent anEvent)
マウスイベントが右マウスボタンを示す場合に true を返します。 |
static String |
layoutCompoundLabel(FontMetrics fm,
String text,
Icon icon,
int verticalAlignment,
int horizontalAlignment,
int verticalTextPosition,
int horizontalTextPosition,
Rectangle viewR,
Rectangle iconR,
Rectangle textR,
int textIconGap)
アイコンの起点位置、テキストのベースラインの起点位置、および可能であればクリップしたバージョンの複合ラベル文字列を計算して返します。 |
static String |
layoutCompoundLabel(JComponent c,
FontMetrics fm,
String text,
Icon icon,
int verticalAlignment,
int horizontalAlignment,
int verticalTextPosition,
int horizontalTextPosition,
Rectangle viewR,
Rectangle iconR,
Rectangle textR,
int textIconGap)
アイコンの起点位置、テキストのベースラインの起点位置、および可能であればクリップしたバージョンの複合ラベル文字列を計算して返します。 |
static void |
paintComponent(Graphics g,
Component c,
Container p,
int x,
int y,
int w,
int h)
矩形の左上隅およびサイズを指定して、指定された矩形内の任意のグラフィックス g でコンポーネント c をペイントします。 |
static void |
paintComponent(Graphics g,
Component c,
Container p,
Rectangle r)
Rectangle オブジェクトを指定して、指定された矩形内の任意のグラフィックス g でコンポーネント c をペイントします。 |
static void |
updateComponentTreeUI(Component c)
単純な Look & Feel の変更で、ツリー内の各ノードに updateUI() 処理を行うこと、つまり現在の Look & Feel でその UI プロパティを初期化することを要求します。 |
static Window |
windowForComponent(Component aComponent)
aComponent のウィンドウを返します。 |
クラス java.lang.Object から継承したメソッド |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
メソッドの詳細 |
public static final boolean isRectangleContainingRectangle(Rectangle a, Rectangle b)
a
が b
を保持する場合に true を返します。public static Rectangle getLocalBounds(Component aComponent)
aComponent
コンポーネントの矩形 (0,0,bounds.width,bounds.height) を返します。public static Point convertPoint(Component source, Point aPoint, Component destination)
source
座標系の aPoint
を destination
座標系に変換します。source
が null の場合、aPoint
は destination
のルートコンポーネント座標系にあるものと想定されます。destination
が null の場合、aPoint
は source
のルートコンポーネント座標系に変換されます。source
と destination
がどちらとも null の場合、変換しないで aPoint
を返します。public static Point convertPoint(Component source, int x, int y, Component destination)
source
座標系の点 (x,y)
を destination
座標系に変換します。source
が null の場合、(x,y)
は destination
のルートコンポーネント座標系にあるものと想定されます。destination
が null の場合、(x,y)
は source
のルートコンポーネント座標系に変換されます。source
と destination
がどちらとも null の場合、変換しないで (x,y)
を返します。public static Rectangle convertRectangle(Component source, Rectangle aRectangle, Component destination)
source
座標系の aRectangle
を destination
座標系に変換します。source
が null の場合、aRectangle
は destination
のルートコンポーネント座標系にあるものと想定されます。destination
が null の場合、aRectangle
は source
のルートコンポーネント座標系に変換されます。source
と destination
がどちらとも null の場合、変換しないで aRectangle
を返します。public static Container getAncestorOfClass(Class c, Component comp)
comp
を検索するための簡易メソッドであり、見つかった c
クラスの最初のオブジェクトを返します。c
クラスが見つからない場合は null を返します。public static Container getAncestorNamed(String name, Component comp)
comp
を検索するための簡易メソッドであり、見つかった name
の最初のオブジェクトを返します。name
が見つからない場合は null を返します。public static Component getDeepestComponentAt(Component parent, int x, int y)
x
、y
を内包する parent
を親として持つ、最下位の可視 Component を返します。parent
が指定された位置を内包していない場合は、null
が返されます。parent
がコンテナではない場合、あるいは parent
の可視の子がどれも指定された位置を内包していない場合は、parent
が返されます。parent
- 検索を開始するルートコンポーネントx
- x ターゲット位置y
- y ターゲット位置public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination)
destination
の座標系に変換済みの場合を除いて、sourceEvent
と同じような MouseEvent を返します。source
が null の場合、sourceEvent
の x と y メンバは destination
のルートコンポーネント座標系に入るものと想定されます。destination
が null
の場合、返された MouseEvent は source
の座標系に入ります。sourceEvent
は変更されません。新しいイベントが返されます。destination が null 以外の場合、返されたイベントの source
フィールドは destination
に設定されます。translateMouseEvent() メソッドを使うと、source を変更しないであるコンポーネントのマウスイベントを別のコンポーネントに変換できます。public static void convertPointToScreen(Point p, Component c)
p
- Point オブジェクト (新しい座標系に変換される)c
- Component オブジェクトpublic static void convertPointFromScreen(Point p, Component c)
p
- Point オブジェクト (新しい座標系に変換される)c
- Component オブジェクトpublic static Window windowForComponent(Component aComponent)
aComponent
のウィンドウを返します。public static boolean isDescendingFrom(Component a, Component b)
a
がコンポーネント b
から派生する場合に true
を返します。public static Rectangle computeIntersection(int x, int y, int width, int height, Rectangle dest)
public static Rectangle computeUnion(int x, int y, int width, int height, Rectangle dest)
public static Rectangle[] computeDifference(Rectangle rectA, Rectangle rectB)
rectB
とオーバーラップしない rectA
内の領域を表現する矩形の配列を返すために使われます。2 つの矩形がオーバーラップしない場合は、空の配列を返します。public static boolean isLeftMouseButton(MouseEvent anEvent)
anEvent
- MouseEvent オブジェクトpublic static boolean isMiddleMouseButton(MouseEvent anEvent)
anEvent
- MouseEvent オブジェクトpublic static boolean isRightMouseButton(MouseEvent anEvent)
anEvent
- MouseEvent オブジェクトpublic static int computeStringWidth(FontMetrics fm, String str)
fm
- 計算に使う FontMetrics オブジェクトstr
- 計算対象の Stringpublic static String layoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap)
public static String layoutCompoundLabel(FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap)
public static void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
g
- 描画先の Graphics オブジェクトc
- 描画対象の Componentp
- 中間コンテナx
- 描画領域の左端を表す int 値 (ピクセル単位)。グラフィックスコンテキストの左端を基準とするy
- 描画領域の上端を表す int 値 (ピクセル単位)。グラフィックスコンテキストの上端を基準とするw
- 描画領域の幅を表す int 値 (ピクセル単位)h
- 描画領域の高さを表す int 値 (ピクセル単位)public static void paintComponent(Graphics g, Component c, Container p, Rectangle r)
g
- 描画先の Graphics オブジェクトc
- 描画対象の Componentp
- 中間コンテナr
- 描画先の Rectanglepublic static void updateComponentTreeUI(Component c)
public static void invokeLater(Runnable doRun)
Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; SwingUtilities.invokeAndWait(doHelloWorld); System.out.println("Waiting ... ");invokeAndWait がイベントディスパッチ元スレッド、たとえば JButtons ActionListener から呼び出された場合、doRun.run() は保留中のすべてのイベントが処理されるまで実行を延期されます。ただし、doRun.run() がキャッチされない例外をスローする場合はイベントディスパッチ元スレッド (現在のスレッドではない) が状態を元に戻すので、注意してください。
このメソッドの追加のドキュメントと例については、このページを参照してください。
invokeAndWait(java.lang.Runnable)
public static void invokeAndWait(Runnable doRun) throws InterruptedException, InvocationTargetException
final Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; Thread appThread = new Thread() { public void run() { try { SwingUtilities.invokeAndWait(doHelloWorld); } catch (Exception e) { e.printStackTrace(); } System.out.println("Finished on " + Thread.currentThread()); } }; appThread.start();ただし、doRun.run() がキャッチされない例外を (イベントディスパッチ元スレッドで) スローする場合は、その例外は呼び出し側スレッドで、InvocationTargetException としてキャッチされて再スローされるので注意してください。
このメソッドの追加のドキュメントと例については、このページを参照してください。
invokeLater(java.lang.Runnable)
public static boolean isEventDispatchThread()
public static int getAccessibleIndexInParent(Component c)
public static Accessible getAccessibleAt(Component c, Point p)
public static AccessibleStateSet getAccessibleStateSet(Component c)
AccessibleState
public static int getAccessibleChildrenCount(Component c)
public static Accessible getAccessibleChild(Component c, int i)
i
- 子のゼロから始まるインデックスpublic static Component findFocusOwner(Component c)
public static JRootPane getRootPane(Component c)
public static Component getRoot(Component c)
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |