3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Convert table co-ordinates correctly in PeerMonitor.

This commit is contained in:
Mike Hearn 2012-12-24 22:53:17 +00:00
parent 8e91459dcc
commit b71015a297

View File

@ -238,8 +238,12 @@ public class PeerMonitor {
public Component getTableCellRendererComponent(JTable table, Object contents,
boolean selected, boolean hasFocus, int row, int column) {
setText(contents.toString());
row = table.convertRowIndexToModel(row);
column = table.convertColumnIndexToModel(column);
String str = contents.toString();
if (model.connectedPeers == null || model.pendingPeers == null) {
setText(str);
return this;
}
@ -253,14 +257,21 @@ public class PeerMonitor {
setFont(normal);
setForeground(Color.BLACK);
// Mark chain heights that aren't normal.
// Mark chain heights that aren't normal but not for pending peers, as we don't know their heights yet.
if (column == PeerTableModel.CHAIN_HEIGHT) {
long height = (Long) contents;
if (height != peerGroup.getMostCommonChainHeight()) {
setText(height + "");
str = height + "";
}
}
}
boolean isPingColumn = column == PeerTableModel.PING_TIME || column == PeerTableModel.LAST_PING_TIME;
if (isPingColumn && contents == (Long)0L) {
// We don't know the answer yet
str = "";
}
setText(str);
return this;
}
}