Swing/BooleanCellEditor のバックアップソース(No.2)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/BooleanCellEditor へ行く。
TITLE:JTableが使用するBooleanCellEditorの背景色を変更 #navi(../) RIGHT:Posted by [[aterai]] at 2010-09-06 *JTableが使用するBooleanCellEditorの背景色を変更 [#t541c708] JTableがデフォルトで使用するBooleanCellEditorの背景色を選択色に変更します。 -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh5.ggpht.com/_9Z4BYR88imo/TQTIJ0rZk-I/AAAAAAAAASU/JvYohArvFpU/s800/BooleanCellEditor.png) **サンプルコード [#ve611f4c] #code{{ JTable table = new JTable(model) { @Override public Component prepareEditor(TableCellEditor editor, int row, int column) { Component c = super.prepareEditor(editor, row, column); if(c instanceof JCheckBox) { ((JCheckBox)c).setBackground(getSelectionBackground()); } return c; } }; }} **解説 [#ybbf81d6] -上:デフォルト --セルをクリックして編集状態になるとCellEditorとして、背景色が白のJCheckBoxが表示される -下:JTable#getSelectionBackground() --BooleanCellEditorとして使用するJCheckBoxの背景色が常にJTable#getSelectionBackground()になるようにJTable#prepareEditor(...)をオーバーライド //**参考リンク **コメント [#d9435978] #comment