Pregunta

I want to get the maximum length for a wave sound, play the track and display its play progress using a JProgressBar. This is what I have done so far but the progress bar is not updating.

Timer t = new Timer(1000,this);

private void playButtonMousePressed(java.awt.event.MouseEvent evt)   {                                        
    // TODO add your handling code here:

   try{
       t.start();
    String track = "tele";
    music = new MusicFunctions(track);
   // music.play(track);

    int progressInit = 0;
    final int len = music.trackLength();
    int tLength = music.trackLength();
    jProgressBar1.setMinimum(0);
    jProgressBar1.setMaximum(len);


    while(i<=len){
    jProgressBar1.setValue(i);
    jProgressBar1.repaint();
    i++;
    }

   }catch(Exception e){
       System.out.println(e);

}                                       
}
¿Fue útil?

Solución

See the SwingWorker documentation; the example is even for updating a progress bar: http://docs.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top