How to add image and text in the same column of table in swings
Rite Sara
Ranch Hand
Joined: Feb 13, 2010
Posts: 56
posted
0
Hi,
I am able to add image to the column using following code :
DefaultTableModel model = new DefaultTableModel(data, columnNames);
JTable table = new JTable( model )
{
// Returning the Class of each column will allow different
// renderers to be used based on Class
public Class getColumnClass(int column)
{
return getValueAt(0, column).getClass();
}
};
But as per my requirement I need to add some text after the image in the same column ..
I tried using label along with image:
label1 = new JLabel(messg ,icon, JLabel.CENTER); model.addRow(new Object[]{fieldName , label1});
But in this case it's not taking the image and showing some source code instead of it ...
Please let me know how I can append some text to an image in the same column ..