@Floris is correct, the string is not "evaluated" as MATLAB code, you need to explicitly write the colors. Here is a small example:
%# data
X = {
'Alice' 1
'Bob' 2
'Charlie' 3
'Dave' 4
};
%# get color from user
c = uisetcolor();
%# format color as: rgb(255,255,255)
%#clr = sprintf('rgb(%d,%d,%d)', round(c*255));
%# format color as: #FFFFFF
clr = dec2hex(round(c*255),2)'; clr = ['#';clr(:)]';
%# apply formatting to third row first column
X(3,1) = strcat(...
['<html><body bgcolor="' clr '" text="#FF0000" width="100px">'], ...
X(3,1));
%# display table
f = figure('Position',[100 100 350 150]);
h = uitable('Parent',f, 'ColumnWidth',{100 'auto'}, ...
'Units','normalized', 'Position',[0.05 0.05 0.9 0.9], ...
'Data',X, 'ColumnName',{'Name','Rank'}, 'RowName',[]);
Note: I tried a few variations of the HTML code. The issue was that the background color was only applied to the text but did not fill the entire table cell:
<html><span style="background-color: #FFFF00; color: #FF0000;">
<html><font style="background-color: #FFFF00; color: #FF0000;">
<html><table cellpadding="0" width="100px" bgcolor="#FFFF00" style="color: #FF0000;"><tr><td>
The last one worked, but its not better than the previous code I showed. I tried other CSS tricks to fill the entire cell space, but failed. I think that the subset of HTML/CSS supported in Java Swing components is limited.
The above HTML approach works fine for small tables. For larger tables or when you want to enable editing, there is a better approach. It requires Java Swing familiarity.