swing - Why is an animated .gif icon not showing in JTable column? -


here processing.gif here processing.gif

here initial.png here initial.png

here output here output

here code. processing.gif working in other locations such in tab of jtabbedpane. here in column of jtable, not showing. explanation , solution? processing.gif moving icon indicates loading.

import javax.swing.*; import javax.swing.table.*;  public class tableicon extends jframe {     public tableicon()     {         imageicon initial = new imageicon(getclass().getresource("initial.png"));         imageicon processing = new imageicon(getclass().getresource("processing.gif"));           string[] columnnames = {"picture", "description"};         object[][] data =         {             {initial, "initial"},             {processing, "processing"}         };          defaulttablemodel model = new defaulttablemodel(data, columnnames);         jtable table = new jtable( model )         {             public class getcolumnclass(int column)             {                 return getvalueat(0, column).getclass();             }         };         table.setpreferredscrollableviewportsize(table.getpreferredsize());          jscrollpane scrollpane = new jscrollpane( table );         getcontentpane().add( scrollpane );     }      public static void main(string[] args)     {         tableicon frame = new tableicon();         frame.setdefaultcloseoperation( exit_on_close );         frame.pack();         frame.setvisible(true);     }  } 

animated gif's don't work default in jtable. there easy way fix this, use animatedicon class can found here

basically, reimplements icon interface, register rendered icon, , when new frame of gif needs painted, automatically repaint correct area.

there alternative provided here register specific imageobserver each cell needs render animated gif, find bit more tedious.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -