Box クラス
- [内容]
- BoxLayout をデフォルトレイアウトとしてもったコンテナです.基本的な機能は,Panel とほとんど同じです.
- [コンストラクタ]
- public Box(int axis)
- Box オブジェクトを生成する.axis は,BoxLayout.X_AXIS (横),または,BoxLayout.Y_AXIS(縦)のいずれかから選択する.
- [主なメソッド]
- public Component add(Component comp) ( Container から継承)
- コンポーネントを付加する
- public Component add(Component comp, int index) ( Container から継承)
- コンポーネントを指定した位置に付加する.index が -1 の場合は最後に付加される.
- public void add(Component comp, Object constraints) ( Container から継承)
- レイアウトマネージャの制約に従って,コンポーネントを付加する
- public void add(Component comp, Object constraints, int index) ( Container から継承)
- レイアウトマネージャの制約に従って,指定された位置にコンポーネントを付加する
- public void add(PopupMenu popup) ( Component から継承)
- ポップアップメニューを付加する
- public void addComponentListener(ComponentListener l) ( Component から継承)
- ComponentListener を付加する
- public void addFocusListener(FocusListener l) ( Component から継承)
- FocusListener を付加する
- public void addKeyListener(KeyListener l) ( Component から継承)
- KeyListener を付加する
- public void addMouseListener(MouseListener l) ( Component から継承)
- MouseListener を付加する
- public void addMouseMotionListener(MouseMotionListener l) ( Component から継承)
- MouseMotionListener を付加する
- public boolean contains(Point p) ( Component から継承)
- public boolean contains(int x, int y) ( JComponent から継承)
- コンポーネントが指定された点を含んでいるか否かを返す(参照: Point クラス)
- public static Component createGlue()
- 不可視の接着剤コンポーネントを生成する.このコンポーネントを付加しておけば,ボックスにスペースが付加されても,固定サイズのコンポーネントのサイズは変化することなく,この接着剤コンポーネントが吸収する.
- public static Box createHorizontalBox()
- コンポーネントを横に並べる Box を生成する
- public static Component createHorizontalGlue()
- 水平方向の接着剤コンポーネントを生成する
- public static Component createHorizontalStrut(int width)
- 不可視の幅が固定されたコンポーネントを生成する
- public static Component createRigidArea(Dimension d)
- 指定された大きさの不可視コンポーネントを生成する
- public static Box createVerticalBox()
- コンポーネントを縦に並べる Box を生成する
- public static Component createVerticalGlue()
- 垂直方向の接着剤コンポーネントを生成する
- public static Component createVerticalStrut(int height)
- 不可視の高さが固定されたコンポーネントを生成する
- public void remove(MenuComponent m) ( Component から継承)
- 指定されたメニューバーを削除する
- public void remove(Component comp) ( Container から継承)
- 指定されたコンポーネントを取り除く
- public void remove(int index) ( Container から継承)
- index で指定されたコンポーネントを取り除く
- public void removeAll() ( Container から継承)
- すべてのコンポーネントを取り除く
- public void removeComponentListener(ComponentListener l) ( Component から継承)
- ComponentListener を取り除く
- public void removeFocusListener(FocusListener l) ( Component から継承)
- FocusListener を取り除く
- public void removeKeyListener(KeyListener l) ( Component から継承)
- KeyListener を取り除く
- public void removeMouseListener(MouseListener l) ( Component から継承)
- MouseListener を取り除く
- public void removeMouseMotionListener(MouseMotionListener l) ( Component から継承)
- MouseMotionListener を取り除く
- public void repaint() ( Component から継承)
- public void repaint(int x, int y, int width, int height) ( Component から継承)
- public void repaint(long tm) ( Component から継承)
- public void repaint(long tm, int x, int y, int width, int height) ( JComponent から継承)
- public void repaint(Rectangle r) ( JComponent から継承)
- 指定された矩形領域を,tm ミリ秒以内に再描画する(参照: Rectangle クラス)
- public void setBackground(Color c) ( JComponent から継承)
- バックグラウンドカラーを設定する
- public void setBounds(int x, int y, int width, int height) ( Component から継承)
- public void setBounds(Rectangle r) ( Component から継承)
- コンポーネントを動かし,大きさを変える(参照: Rectangle クラス)
- public void setEnabled(boolean b) ( JComponent から継承)
- コンポーネントを enable,または,disable にする.disable にするとイベントを受け付けなくなる.
- public void setFont(Font f) ( JComponent から継承)
- コンテナのフォントを設定する
- public void setForeground(Color c) ( JComponent から継承)
- フォアグラウンドカラーを設定する
- public void setLocation(int x, int y) ( Component から継承)
- public void setLocation(Point p) ( Component から継承)
- コンポーネントの位置を設定する(参照: Point クラス)
- public void setName(String name) ( Component から継承)
- コンポーネントの名前を設定する
- public void setSize(int width, int height) ( Component から継承)
- public void setSize(Dimension d) ( Component から継承)
- コンポーネントの大きさを width ( d.width ),height ( d.height ) に設定する( Dimension については,プログラム例を参照)
- public void setVisible(boolean b) ( JComponent から継承)
- コンポーネントを表示,非表示にする
- [使用例]
- プログラム例は,テキストエリア,テキストフィールド,ラベル,及び,ボタンを,Box クラスを利用して横に配置した例です.ここをクリックするとアプレット版が表示されます(プログラム).

- プログラム例は,テキストエリア,テキストフィールド,ラベル,及び,ボタンを,BoxLayout によって横に配置した例です.ここをクリックするとアプレット版が表示されます(プログラム).

- プログラム例は,2 つのコンテナ( Box クラスのコンテナ)を用意し,テキストエリアを一つのコンテナに,また,不可視のコンポーネント,テキストフィールド,ラベル,及び,ボタンを,他の一つのコンテナへ縦に配置した例です.ここをクリックするとアプレット版が表示されます(プログラム).

- プログラム例は,2 つのパネルを用意し,テキストエリアを一つのパネルに,また,テキストフィールド,ラベル,及び,ボタンを,他の一つのパネルに BoxLayout によって縦に配置した例です.ここをクリックするとアプレット版が表示されます(プログラム).

- [参照]
- BoxLayout, GridBagLayout, GridLayout, CardLayout, FlowLayout, BorderLayout, Panel, JPanel