I want to display a graphic e.g. gif resource and a currency number in a single jtable cell. below is the code for he cell renderer ,it displays the currency as expected but the graphic is distorted in the cell. Any suggestion
public class CurrencyCellRenderer extends DefaultTableCellRenderer {
private final ImageIcon cediImage =
new ImageIcon (getClass().getResource("/resources/images/cedi.gif"));
public CurrencyCellRenderer() {
super();
setHorizontalAlignment(SwingConstants.LEFT);
}
@Override
public void setValue(Object value) {
if ((value != null) && (value instanceof Number)) {
Number numberValue = (Number) value;
NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("ghs" ,"GH"));
value = formatter.format(numberValue.doubleValue());
}
super.setIcon(cediImage);
super.setValue(value);
}
}
below is the code attaching the cellrenderer to the table
jTable.setDefaultRenderer(Double.class , new CurrencyCellRenderer());
thank you all.