• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Objects in one JTable cell

 
Andraz Poje
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Is it possible to add more than one ImageIcon object to one cell?
This is my code. It works fine.



What should I do to add more than one image to 1 cell?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andraz Poje wrote:Hi. Is it possible to add more than one ImageIcon object to one cell?


What should I do to add more than one image to 1 cell?


http://tips4java.wordpress.com/2009/03/22/dual-icon/
http://tips4java.wordpress.com/2009/03/29/compound-icon/

Note that these Icon implementations don't play well with an ImageIcon that holds an animated GIF.
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can store multiple objects in a table cell indirectly - through an array or collection. That won't render the way you want though.

For showing two ImageIcons you can use a workaround though - use a custom Icon implementation, and make getColumnClass return Icon.class instead of ImageIcon.class. This custom implementation is not hard (pseudo code):
 
Andraz Poje
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compound Icon works great. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic