Swing/ComboCellEditor のバックアップの現在との差分(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/ComboCellEditor へ行く。
- 1 (2005-09-24 (土) 15:34:27)
- 2 (2005-09-28 (水) 06:46:03)
- 3 (2005-11-04 (金) 12:28:23)
- 4 (2006-02-27 (月) 15:35:45)
- 5 (2006-02-27 (月) 16:54:59)
- 6 (2006-04-12 (水) 19:38:51)
- 7 (2006-06-23 (金) 14:00:00)
- 8 (2007-03-15 (木) 15:31:47)
- 9 (2007-03-19 (月) 02:34:08)
- 10 (2007-10-04 (木) 01:31:14)
- 11 (2009-06-09 (火) 20:33:16)
- 12 (2013-03-24 (日) 21:26:01)
- 13 (2013-05-03 (金) 23:50:35)
- 14 (2015-10-14 (水) 15:34:24)
- 15 (2015-12-21 (月) 00:49:59)
- 16 (2016-06-05 (日) 23:51:14)
- 17 (2016-09-07 (水) 15:36:45)
- 18 (2017-06-02 (金) 15:24:08)
- 19 (2018-05-23 (水) 21:18:12)
- 20 (2020-05-20 (水) 09:10:58)
- 21 (2021-11-07 (日) 05:31:32)
- 追加された行はこの色です。
- 削除された行はこの色です。
#navi(../) *JTableのCellEditorにJComboBoxを設定 [#f57b6c70] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2005-09-26~ 更新日:&lastmod; --- category: swing folder: ComboCellEditor title: JTableのCellEditorにJComboBoxを設定 tags: [JTable, TableCellEditor, JComboBox, TableColumn] author: aterai pubdate: 2005-09-26T15:27:12+09:00 description: JTableのCellEditorにJComboBoxを使用し、リストから値を選択できるようにします。 image: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTJy9xBM6I/AAAAAAAAAU8/h5YELRcY4gE/s800/ComboCellEditor.png --- * 概要 [#summary] `JTable`の`CellEditor`に`JComboBox`を使用し、リストから値を選択できるようにします。 #contents #download(https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTJy9xBM6I/AAAAAAAAAU8/h5YELRcY4gE/s800/ComboCellEditor.png) **概要 [#v4c613bd] JTableのCellEditorにJComboBoxを使用し、リストから値を選択できるようにします。 * サンプルコード [#sourcecode] #code(link){{ JComboBox cb = new JComboBox(new String[] {"名前0", "名前1", "名前2"}); cb.setBorder(BorderFactory.createEmptyBorder()); http://terai.xrea.jp/swing/combocelleditor/screenshot.png TableColumn col = table.getColumnModel().getColumn(1); col.setCellEditor(new DefaultCellEditor(cb)); // col.setCellRenderer(new ComboBoxCellRenderer()); }} **サンプルコード [#y53e1620] * 解説 [#explanation] 上記のサンプルでは、`1`列目のセルエディタとしてコンボボックスを使う`DefaultCellEditor`を登録しています。 -[[サンプルを起動>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]] - コンボボックスの余白を`0`に設定しないとセル内文字列の上下が欠けてしまう場合がある #ref(https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTJ1Ykl--I/AAAAAAAAAVA/ZRLgScHCF3s/s800/ComboCellEditor1.png) -- 参考: [http://www.jroller.com/page/santhosh?entry=tweaking_jtable_editing Santhosh Kumar's Weblog : Santhosh Kumar's Weblog] **解説 [#k4fd12f0] * 参考リンク [#reference] - [http://www.jroller.com/page/santhosh?entry=tweaking_jtable_editing Santhosh Kumar's Weblog : Santhosh Kumar's Weblog] - [[JTableのCellRendererにJComboBoxを設定>Swing/ComboCellRenderer]] -- セルの表示にも`JComboBox`を使用する場合は`JComboBox`を継承するセルレンダラーを使用する - [[JComboBoxセルエディタのドロップダウンリストを編集開始直後は表示しないよう設定する>Swing/CellEditorTogglePopup]] **参考リンク [#w85587e3] **コメント [#naf1e6fc] * コメント [#comment] #comment #comment