1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| class CenterRenderer extends DefaultTableCellRenderer
{
public CenterRenderer()
{
setHorizontalAlignment( CENTER );
}
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
if(column == 0)
{
String str = (String)(((String[])BigThr.playerVector.elementAt(row))[1]);
int temp = Integer.parseInt(str)-1;
String country = (String)TanX.countriesCombo.getItemAt(temp);
String status = ((String[])BigThr.playerVector.elementAt(row))[4];
status = "present";
if(status.trim().equals("0")) status = "away";
setToolTipText("country: "+country+", status: "+status);
}
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isSelected)
{
setBackground( table.getSelectionBackground() );
}
else
setBackground( table.getBackground() );
return this;
}
public void editingStopped(ChangeEvent e)
{
//write ur code here
}
// The following methods override the defaults for performance reasons
public void validate() {}
public void revalidate() {}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
} |
Partager