Here is the processing.gif
Here is initial.png
Here is the output
Here is the code. processing.gif is working in other locations such as in the tab of a JTabbedPane
. Here in the column of a JTable
, it is not showing. Any explanation and solution? processing.gif is a moving icon that indicates that something is loading.
import javax.swing.*;
import javax.swing.table.*;
public class TableIcon extends JFrame
{
public TableIcon()
{
ImageIcon initial = new ImageIcon(getClass().getResource("initial.png"));
ImageIcon processing = new ImageIcon(getClass().getResource("processing.gif"));
String[] columnNames = {"Picture", "Description"};
Object[][] data =
{
{initial, "initial"},
{processing, "processing"}
};
DefaultTableModel model = new DefaultTableModel(data, columnNames);
JTable table = new JTable( model )
{
public Class getColumnClass(int column)
{
return getValueAt(0, column).getClass();
}
};
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
}
public static void main(String[] args)
{
TableIcon frame = new TableIcon();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}
}