JTabbedPane クラス
- [内容]
- コンポーネントを重ねて配置し,各コンポーネントにタブを付ける場合に使用されます
- [主な変数]
- public static final int BOTTOM ( SwingComponents から継承)
- 下
- public static final int LEFT ( SwingComponents から継承)
- 左
- public static final int RIGHT ( SwingComponents から継承)
- 右
- public static final int TOP ( SwingComponents から継承)
- 上
- [コンストラクタ]
- public JTabbedPane()
- public JTabbedPane(int tabPlacement)
- タブの位置を指定( TabbedPane.BOTTOM,TabbedPane.LEFT,TabbedPane.RIGHT,または,TabbedPane.TOP )して,JTabbedPane オブジェクトを生成する
- [主なメソッド]
- public Component add(Component component)
- public Component add(Component component, int index)
- public void add(Component component, Object constraints)
- public void add(Component component, Object constraints, int index)
- public Component add(String title, Component component)
- 指定された位置に(省略すると,最後に),タブ付き(タブのタイトル: title )のコンポーネントを付け加える.title を入力しないと,コンポーネントと同じ名前になる.constraints が String,または,Icon の場合は,タブタイトルとして使用され,そうでない場合は,コンポーネントの名前がタブタイトルとなる.
- public void addChangeListener ( ChangeListener l )
- ChangeListener を付け加える
- public void addTab(String title, Component component)
- public void addTab(String title, Icon icon, Component component)
- public void addTab(String title, Icon icon, Component component, String tip)
- title と icon (片方を null にし,いずれか一つでも良い)を持ったタブ付きのコンポーネントを付け加える.tip とは,タブで表示されるツールヒントである.
- public Component getSelectedComponent()
- 選択されているコンポーネントを返す
- public int getSelectedIndex()
- 選択されているコンポーネント番号を返す
- public void insertTab(String title, Icon icon, Component component, String tip, int index)
- 引数で指定されたタブ付きのコンポーネントを挿入する
- public void paint(Graphics g) ( JComponent から継承)
- コンポーネントを描画
- public void paintAll(Graphics g) ( Component から継承)
- このコンポーネントおよびそのすべてのサブコンポーネントを描画
- public void paintComponent(Graphics g) ( JComponent から継承)
- コンポーネントを描画
- public void paintComponents(Graphics g) ( Container から継承)
- コンテナ内の各コンポーネントを描画
- public void remove(Component component)
- public void remove(int index)
- 指定されたコンポーネントを取り除く
- public void removeAll()
- すべてのコンポーネントを取り除く
- public void removeChangeListener ( ChangeListener l )
- ChangeListener を取り除く
- public void removeTabAt(int index)
- 指定されたコンポーネントを取り除く
- 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(Rectangle r) ( JComponent から継承)
- public void repaint(long tm, int x, int y, int width, int height) ( JComponent から継承)
- 指定された矩形領域を,tm ミリ秒以内に再描画する
- public void setBackgroundAt ( int index, Color background )
- 指定されたコンポーネントのバックグラウンドカラーを設定する
- public void setComponentAt ( int index, Component component )
- 指定されたコンポーネントを,component に変える
- public void setEnabledAt ( int index, boolean enabled )
- 指定されたコンポーネントを,イネーブル,または,イネーブルでなくす
- public void setForegroundAt ( int index, Color foreground )
- 指定されたコンポーネントのフォアグラウンドカラーを設定する
- public void setIconAt ( int index, Icon icon )
- 指定されたコンポーネントのアイコンを,icon に変える
- public void setSelectedComponent ( Component c )
- 指定されたコンポーネントを選択する
- public void setSelectedIndex ( int index )
- 指定されたコンポーネントを選択する
- public void setTitleAt(int index, String title)
- 指定されたコンポーネントのタイトルを,title に変える
- [使用例]
- プログラム例は,JTabbedPane クラスの各メソッド等の使用例です.タブをクリックすることによって,画像が変化します.

- [参照]
- JSplitPane, BoxLayout, GridBagLayout, GridLayout, CardLayout, FlowLayout, BorderLayout, ChangeEvent, ChangeListener