/**
* Renders the icon for a state.
*/
package com.mindprod.vercheck;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
/**
* render a the AppSate enum cell, use icon without text.
*/
final class AppStateRenderer extends DefaultTableCellRenderer implements TableCellRenderer
{
/**
* constructor
*/
public AppStateRenderer()
{
}
/**
* Prepare a JLabel with the relevant icon in it.
*
* @param table the JTable
* @param value the ImageIcon to display
* @param isSelected true if this cell is selected.
* @param hasFocus true if this cell has focus
* @param row 0-based row
* @param column 0-based column
* @return JLabel with an Icon in it.
*/
public Component getTableCellRendererComponent( JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column )
{
JLabel template = ( JLabel ) super.getTableCellRendererComponent( table, value,
isSelected, hasFocus, row, column );
template.setHorizontalAlignment( JLabel.CENTER );
template.setText( "" );
template.setIcon( ( ImageIcon ) value );
return template;
}
}