wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Multiple Objects in one JTable cell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Multiple Objects in one JTable cell" Watch "Multiple Objects in one JTable cell" New topic
Author

Multiple Objects in one JTable cell

Andraz Poje
Ranch Hand

Joined: Sep 25, 2008
Posts: 32
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

Joined: Oct 13, 2005
Posts: 37953
    
  22
Moving to our GUIs forum.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

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):


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Andraz Poje
Ranch Hand

Joined: Sep 25, 2008
Posts: 32
Compound Icon works great. Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple Objects in one JTable cell
 
Similar Threads
Images in a JTable
JTable Question
JTable shows previous data
JTable
problem in JTable