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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Thumbnail inside JTable" Watch "Thumbnail inside JTable" New topic
Author

Thumbnail inside JTable

Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Can I put a thumbnail inside a JTable?

I create my table from a defaultmodel, then I try this:

And I get inside the cell the memory reference:
javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.ImageIcon@59a34,disabledIcon=,horizontalAlignment=CENTER,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER]

Does anybody know how to put an image inside a JTable??
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
try getTabla().getModel().setValueAt(icono, i, 4)


bitguru blog
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
I forgot to say that I had already done that, but thanks anyway, that doesn't works either, the same thing happens. I think I have to implement a ColumnRenderer, I'll search the forums for some advice. Anyone can tell me where to find it?
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
You'll have to roll your own renderer, or find a third party renderer that does this. I believe this specific implementation is actually covered in the tutorial at the Sun website.

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Actually, JTable does have default renderers
for Icons, but it won't use them unless you
return Icon.class or ImageIcon.class in your
table model's getColumnClass() method.

I should have mentioned that in my previous
posting, sorry. It's the same deal with other
column types such as Boolean, Date, and the
Number classes.

Since you say you're using DefaultTableModel,
you'll have to do something like create an
anonymous inner class to override that method.
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
I've decided not to add thumbnails on my JTable, because creating saceld images requires so much time, and as I don't really need thumbnails I prefer keeping the system fast. Thanks anyway if I have some free time I'll try to add thumbnails to the tables, but first I've got other things to do. Thanks anyway.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
BufferedImage offers software acceleration.
 
Consider Paul's rocket mass heater.
 
subject: Thumbnail inside JTable
 
Similar Threads
Image Renderer for JTable
Resize ImageIcon
jtable
JTable
Show images in a JPanel