NSTableView and tableViewWillDisplayCell
NSTableView and tableViewWillDisplayCell
- Subject: NSTableView and tableViewWillDisplayCell
- From: Simon Wright <email@hidden>
- Date: Sun, 30 Sep 2001 20:21:07 -0400
I have an NSTableView which has a column in which I'd like to place a
small graphic (in this case it represents the status of something that the
row refers to). For example I'd like to put a green square when the status
is good and a red square when trouble looms.
I have created a couple of jpegs and loaded them into NSImage objects like
this...
statusGoodImage = new NSImage("StatusGood.jpg", true);
statusBadImage = new NSImage("StatusBad.jpg", true);
I have created my own cell like this...
private static NSImageCell statusCell = new NSImageCell();
I have changed the appropriate cell from test to image like this...
NSTableColumn statusTableColumn = aTableView.tableColumnWithIdentifier(
"statusColumn");
statusTableColumn.setDataCell(statusCell);
and I have a method that does the tableViewWillDisplayCell stuff like this.
..
public void tableViewWillDisplayCell(NSTableView aTableView, NSCell
aCell, NSTableColumn aTableColumn, int rowIndex) {
NSApplication.beep(); //let me know if it's getting called
if (aTableColumn.identifier().toString().equals("statusColumn")) {
if (statusArray.objectAtIndex(rowIndex) == "")
aCell.setImage(statusGoodImage);
else
aCell.setImage(statusBadImage);
}
}
but it is never getting called when my table is displayed. How does my
tableview know that it should be calling this method. I'm sure I'm missing
some vital "connection". Your help is appreciated.
Simon
(Hoping that one he'll be able to help others on this list).