Bookmark Topic Watch Topic
  • New Topic

How to add image and text in the same column of table in swings

 
Rite Sara
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Report post to moderator
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 ..



Thanks,


 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please UseOneThreadPerQuestion. Let's stick to your existing thread, shall we?
 
    Bookmark Topic Watch Topic
  • New Topic