Forums Register Login

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

+Pie Number of slices to send: Send
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,


+Pie Number of slices to send: Send
Please UseOneThreadPerQuestion. Let's stick to your existing thread, shall we?
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


Reply locked
This thread has been viewed 1450 times.
Similar Threads
JTable ........
Cannot uncheck JCheckBox in JTable
Jtable
JTable
JTable(!!!)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:56:10.