/*
 * FormatedRenderer.java
 *
 * Created on Ketvirtadienis, 2007, Sausio 25, 17.16
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Main.panels;

import java.awt.*;
import java.text.*;
import javax.swing.*;
import javax.swing.table.*;


public class FormatedRenderer extends DefaultTableCellRenderer
{
	public Component getTableCellRendererComponent(JTable table, Object value,
					  boolean isSelected, boolean hasFocus, int row, int column) 
	{
		JLabel field= (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		NumberFormat format= NumberFormat.getInstance();
		String text= value.toString();
		if(value instanceof Float)
		{
			text= format.format( ((Float)value).doubleValue() );
		}
		else if(value instanceof Double) 
		{
			text= format.format( ((Double)value).doubleValue() );
		}
		field.setText( text );
		return field;
	}
}

