/*
 * ProgressBarCellRenderer.java
 *
 * Created on March 27, 2006, 8:39 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.businesslogic.ireport.plugin.locale;

import java.awt.Component;
import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author gtoffoli
 */
public class ProgressBarCellRenderer extends JProgressBar implements TableCellRenderer {
    
    /** Creates a new instance of ProgressBarCellRenderer */
    public ProgressBarCellRenderer() {
        super(0,100);
        this.setStringPainted(true);
    }

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        double val = 0;
        try {
            val = Double.parseDouble(""+value);
        } catch (Exception ex)
        {
            
        }
        this.setString(""+(int)val+"%");
        this.setValue((int)val);
        return this;
    }
    
}
