私はjtableを持っていて、セルを選択するときに、このセルの行全体と列全体の背景を変更したい(セルの背景のみを変更しないでください!)、どうすればいいですか?
アドバイスしてください、ありがとう。
私はjtableを持っていて、セルを選択するときに、このセルの行全体と列全体の背景を変更したい(セルの背景のみを変更しないでください!)、どうすればいいですか?
アドバイスしてください、ありがとう。
以下を使用して、列の色を制御しました。現在のセルを組み込む方法については、 http://www.javaworld.com/javaworld/javaqa/2001-09/03-qa-0928-jtable.htmlを参照してください。
this.table = new JTable()
{
private static final long serialVersionUID = -5739534894469353266L;
/**
* Set the background color of the row equal to the color of the path in the map
*/
@Override
public Component prepareRenderer( final TableCellRenderer renderer, final int Index_row, final int Index_col )
{
final Component comp = super.prepareRenderer( renderer, Index_row, Index_col );
// even index, selected or not selected
if ( Index_col == 1 )
{
// Color column, match foreground / background colors
comp.setBackground( MyColors.getColor( Index_row ) );
comp.setForeground( MyColors.getColor( Index_row ) );
}
else
{
comp.setBackground( Color.white );
comp.setForeground( Color.black );
}
return comp;
}
};