JLabel クラス
- [内容]
- 文字列やイメージを表示するためのクラスです
- [主な変数]
- public static final int CENTER ( SwingConstants から継承)
- 中央を示す
- public static final int LEADING ( SwingConstants から継承)
- リーディングエッジを示す
- public static final int LEFT ( SwingConstants から継承)
- 左を示す
- public static final int RIGHT ( SwingConstants から継承)
- 右を示す
- public static final int TRAILING ( SwingConstants から継承)
- トレーリングエッジを示す
- [コンストラクタ]
- public JLabel()
- public JLabel(Icon image)
- public JLabel(Icon image, int horizontalAlignment)
- public JLabel(String text)
- public JLabel(String text, Icon icon, int horizontalAlignment)
- public JLabel(String text, int horizontalAlignment)
- JLabel オブジェクトを生成する.水平方向の位置( horizontalAlignment )は,LEFT,CENTER,RIGHT,LEADING,または,TRAILING から選択する.
- [主なメソッド]
- public void setBackground(Color c) ( JComponent から継承)
- バックグラウンドカラーを設定する
- public void setFont(Font f) ( JComponent から継承)
- フォントを設定する
- pu blic void setForeground(Color c) ( JComponent から継承)
- フォアグラウンドカラーを設定する
- public void setHorizontalTextPosition(int textPosition)
- ラベルテキストのイメージに対する水平位置を設定する.LEFT,CENTER,RIGHT,LEADING,または,TRAILING から選択する.
- public void setIcon(Icon icon)
- アイコンを設定する
- public void setIconTextGap(int iconTextGap)
- テキストとアイコンの間隔を設定する
- public void setText(String text)
- テキストを設定する
- public void setVisible(boolean b) ( JComponent から継承)
- コンポーネントを表示,非表示にする
- [使用例]
- プログラム例は,JLabel クラスの各メソッド等の使用例です.上部に文字のラベルが,また,中央には,文字とアイコンを持ったラベルが貼り付けてあります.ここをクリックするとアプレット版が表示されます(プログラム).

- [参照]
- Label