Find number in uitable

1 view (last 30 days)
john
john on 8 May 2012
Hi,
I have uitable, columns and rows are changing, there are not still the same. At first I can insert number only for the first column. If everything is OK, then I can insert number to the next column. If I insert number one or minus one into uitable, and after that if uitable consist more then one "1" or more then "-1", then I need write "Error with 1" or " Error with -1" or "Error with 1 and -1" into edittext, and also I want to set background color to red only for one cell in uitable for last bad inserted number.
Maybe therefore I will need, how to set background color only for one cell.
And maybe I should create any cycle, loop with "for" instruction to searching number "1" and number "-1". In case, if I find number more than one "1" or more than one "-1", I should stop this cycle.
So how can I stop this cycle?
Thank you for help

Accepted Answer

Jan
Jan on 8 May 2012
You can set the foreground color using the semi-documented method of HTML markup as described in MathWorks solution 1-D782JW. But as soon as you edit the value, the HTML tags are very confusing.
The background color can be set by undocumented Java methods only, see: Undocumented: uitable-cell-colors.
I do not understand what you want to do with the 1's and -1's, but testing the values of a column can be done in the CellEditCallback. If you want a limited list of values only, a popup menu seems to be helpful.
  1 Comment
john
john on 10 May 2012
Hi Jan,
is this command OK?
cr = ColoredFieldCellRenderer(java.awt.Color.white);
cr.setCellBgColor(1,1,java.awt.Color(1,1,0)); % yellow

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!