• 追加された行はこの色です。
  • 削除された行はこの色です。
#navi(../)
*JTableのCellEditorにJComboBoxを設定 [#f57b6c70]
>編集者:[[Terai Atsuhiro>terai]]~
作成日:2005-09-26~
更新日:&lastmod;

#contents

**概要 [#v4c613bd]
JTableのCellEditorにJComboBoxを使用し、リストから値を選択できるようにします。

http://terai.xrea.jp/swing/combocelleditor/screenshot.png

**サンプルコード [#y53e1620]
 JComboBox combo = new JComboBox();
 combo.addItem("名前0");
 combo.addItem("名前1");
 combo.addItem("名前2");
 table.setDefaultEditor(JComboBox.class, new DefaultCellEditor(combo));

-[[サンプルを起動>http://terai.xrea.jp/swing/combocelleditor/sample.jnlp]]
-[[jarファイル>http://terai.xrea.jp/swing/combocelleditor/sample.jar]]
-[[ソース>http://terai.xrea.jp/swing/combocelleditor/src.zip]]

**解説 [#k4fd12f0]
コンボボックスを使うDefaultCellEditorオブジェクトを生成し、JTable#setDefaultEditorメソッドでこれを設定しています。

**参考リンク [#w85587e3]
-[[JTable Examples>http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples7.html]]

**コメント [#naf1e6fc]
#comment