Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/11/2013, 16:01
ilu7ionHD
Invitado
 
Mensajes: n/a
Puntos:
Que hace este codigo?

//Clase ResponseFile:
import java.awt.Toolkit;

import javax.swing.SwingWorker;

public class ResponseFile extends SwingWorker<String, Void>{
@Override
protected String doInBackground() throws Exception {

for (int i = 0; i <= 20; i++) {
setProgress((i+1) * 100 / 20);
Thread.sleep(500);
}
return "";
}

@Override
protected void done() {
setProgress(100);
Toolkit.getDefaultToolkit().beep();
}
}

//JFRAME:

ResponseFile response = new ResponseFile(){
@Override
protected void done()
{
dispose();
principal.setVisible(true);


}
};
response.addPropertyChangeListener(new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if ("progress".equals(event.getPropertyName())) {
principal.primaria();
progressBar.setValue( (Integer)event.getNewValue() );
}
}
});
response.execute();

//Aclaración : Se usa para la progressBar