File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 36486
    
  16
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: 19543
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Objects in one JTable cell
 
Similar Threads
JTable
JTable shows previous data
problem in JTable
JTable Question
Images in a JTable