0

I have an arraylist of object with the properties Title, Director, Rating, and the pathname for an image. I am wanting dynamically fill the JTable with this data in a for loop as illustrated by the following pseudo-code:

for(int i = 0; i < movieCatalog.size(); i++)
{ 
   imageCell = movieCatalog.get(i).getImagePath();
   titleCell = movieCatalog.get(i).getTitle();
   directorCell = movieCatalog.get(i).getDirector();
   ratingCell = movieCatalog.get(i).getRating();
} 

So for each slot in the arraylist I want to put the data into their respective cells in each row.

How do I put the image into each cell?. I understand that I need to set up an image render but I don't know how to do this. Code for adding data to the table, and the image renderer would be much appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
batsta13
  • 549
  • 2
  • 12
  • 26
  • Have you searched a lot and didn't found an answer and needed to open a new one? http://stackoverflow.com/questions/3222951/java-put-image-in-jtable-cell –  May 31 '13 at 12:31
  • 1
    read this: http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/ – Aboutblank May 31 '13 at 12:31
  • yes i've been searching alot. I wanted to rewrite my problem in hopes of getting an answer that will actually work. – batsta13 May 31 '13 at 12:32
  • Take a look at [this](http://stackoverflow.com/questions/16847271/adding-an-image-to-jtable-cell/16847466#16847466) example – MadProgrammer May 31 '13 at 12:36
  • *Code for adding data to the table, and the image renderer would be much appreciated* To which address do I send my invoice ? There is a whole [`JTable` tutorial](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html) which should allow you to at least add the data to the table – Robin May 31 '13 at 12:53

1 Answers1

2

How do I put the image into each cell?. I understand that I need to set up an image render but I don't know how to do this.

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319