Caros, simplifiquei o código da minha tela que é um JFrame. Ao se clicar no botão eu inicio um processo e quero exibir um JProgressBar num JDialog enquanto o processo executa. Só que a droga do Dialog não renderiza na tela direito. Alguma luz?
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Teste extends JFrame {
public Teste() {
getContentPane().setLayout( new FlowLayout() );
getContentPane().add( new JTextField("FUCK THE WORLD!") );
JButton b = new JButton("OK");
getContentPane().add( b );
setLocationRelativeTo(null);
b.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Progress p = new Progress();
Thread t = new Thread( p );
t.start();
//faz algo aqui
try {
Thread.sleep(5000);
} catch( Exception e ) {}
p.dispose();
}
}
);
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
pack();
}
public static void main(String[] args) {
Teste t = new Teste();
t.show();
}
}
class Progress extends JDialog implements Runnable {
public Progress() {
setModal(true);
setLocationRelativeTo(null);
JProgressBar j = new JProgressBar();
j.setIndeterminate(true);
j.setSize(200,20);
getContentPane().add(j);
pack();
}
public void run() {
this.show();
}
}