Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView and tableViewWillDisplayCell



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).




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.