I'm currently dealing with quite a huge thing...
My cellRenderer is here to give a button aspect, this button has 3 kind of icons in fact :
a cross when the line is ready to be treated
a loading animation while in treatment... and here is the problem
a tick whe the line has been treated
i see the loader (but not always...) and not animated at all ...
I change the states of the button in aother class, which has its own thread....
.. as for no as see the lines being ticked line by line, cool, but if the loader could move between the 2 step, it would be perfect..
Here is my class :
/**
* Create a special cell render for the first column of the images table
* This cell render let us display a JButton associated with the given file in order
* to permit its deletion from the tablelist
* @author Gregory Durelle
*
*/
public class DeleteCellRender extends JButton implements TableCellRenderer , Runnable{
private static final long serialVersionUID = 1L;
int row;
JTable table;
public DeleteCellRender(){
this.setIcon(Smash.getIcon("cross.png"));
this.setBorderPainted(false);
this.setForeground(Color.WHITE);
this.setOpaque(false);
this.setFocusable(false);
}
public Component getTableCellRendererComponent( JTable table, Object value,boolean selected, boolean focused, int row, int column) {
this.setBackground(table.getBackground());
if(((DataModel)table.getModel()).getImageFile(row).isSent()){
this.setIcon(Smash.getIcon("tick.png"));//Smash is my main class & getIcon a static method to retrieve icons throug getRessource(url) stuff
this.setToolTipText(null);
}
else if(((DataModel)table.getModel()).getImageFile(row).isSending()){
this.setIcon(Smash.getIcon("loader.gif")); //HERE IS THE PROBLEM, IT SHOULD BE ANIMATED :(
this.setToolTipText(null);
this.row=row;
this.table=table;
Thread t = new Thread(this);
t.start();
}
else{
this.setIcon(Smash.getIcon("cross.png"));
this.setToolTipText("Delete this image from the list");
}
return this;
}
public void run() {
while(true){
repaint();//SEEMS TO DO NO DIFFERENCE...
}
}
}
I tried to add a no-ending repaint but it does not make any difference... so if the Runnable annoy you, consider it deosn't exist ;)
Someone has any idea of how to make an animated gif in a JButton which is in fact a CellRenderer ??....
.. or maybe a better idea to make the loader appearing at the place of the cross, before the appearition of the tick....
Edited by: GreGeek on 11 juil. 2008 23:04