Possible Duplicate:
Swing - Setting the color of a cell based on the value of a cell
I have a Spreadsheet class, containing a JTable and its TableModel. And my main window contains this spreadsheet and a list of buttons, with for example a bold one.
I can successfully get the selected cell (see code below), but I have no idea of how to change its content and font, color etc.
public void actionPerformed(ActionEvent e)
{
int rowToUpdate = -1, columnToUpdate = -1;
for(int i = 0 ; i < tableToUpdate.getRowCount() ; i++)
for (int j = 0 ; j < tableToUpdate.getColumnCount() ; j++)
if(tableToUpdate.isCellSelected(i, j)){ rowToUpdate = i; columnToUpdate = j; }
if(rowToUpdate >= 0 && columnToUpdate >= 0)
{
if(e.getSource == boldButton)
{
// Here, how to change the bold of the cell(rowToUpdate,columnToUpdate)
}
}
}