• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thumbnail inside JTable

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try getTabla().getModel().setValueAt(icono, i, 4)
 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BufferedImage offers software acceleration.
 
reply
    Bookmark Topic Watch Topic
  • New Topic