ComboBoxRenderer里面的内容,如下:
@Override
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
oddColor = ResManager.getColor("Trade.OrderBook.TableCell.OddColor");
evenColor = ResManager.getColor("Trade.OrderBook.TableCell.EvenColor");
fgColor = ResManager.getColor("Trade.OrderBook.TableCell.textColor");
highlightBgColor = HVResMgr.getColor("Trade.OrderBook.TableCell.HighlightColor");
//set line background color
if ((row % 2) == 0) {
bgColor = oddColor;
}
else {
bgColor = evenColor;
}
// set highlight color
if (isSelected) {
bgColor = highlightBgColor;
}
//calculate the font size
double ratio = 1.0;
if (table instanceof BaseTable) {
ratio = ((BaseTable) table).getRatio();
}
int fontSize = (int) (font.getSize() * ratio);
font = new Font(font.getName(), font.getStyle(), fontSize);
this.comboBox.setBorder(null);
this.comboBox.setBackground(bgColor);
this.comboBox.setForeground(fgColor);
if (column == 3) {
StatusType status = null;
switch ((Character) value) {
case 'A' :
status = StatusType.Active;
break;
case 'S' :
status = StatusType.Suspended;
break;
case 'D' :
status = StatusType.Deleted;
break;
default :
break;
}
this.comboBox.setSelectedItem(status);
}
return this.comboBox;
}