I am trying to convert my object[][]
to an ImageIcon
. I current have a public Object[][] images;
where I store my images. How do I convert this to an ImageIcon so that I can use it to put it into my JTable? I have tried this:
for(int i = 0; i < 100; i++)
{
...
ImageIcon icon = new ImageIcon(images[i].toString());
// add to table
}
Nothing shows in my table and if I print the value out from the cell this shows: [Ljava.lang.String;@72787a6f
Thanks for any answer.
You have a 2D array so you need to use another index to reference the element at row i
column j
for (int i = 0; i < images.length; i++) {
for (int j = 0; j < images[i].length; j++) {
ImageIcon icon = new ImageIcon(images[i][j].toString());
...
}
}
It would make more sense to use a String[][]
array