I've been writing an ftp server app and i need to show an indeterminate progressbar on the screen.But it won't show. I've repainted the user interface,yet it won't show. the code is:
JProgressBar pb = new JProgressBar();
pb.setIndeterminate(true);
pb.setStringPainted(true);
pb.setString("Transferring files...");
pb.setVisible(true);
pb.setBounds(0, 0, 600, 300);
if (files.length > 0) {
remove(panel);
add(pb);
this.revalidate();
this.repaint();
} else {
JOptionPane.showMessageDialog(this, "Select files to send!", "ERROR!", JOptionPane.ERROR_MESSAGE);
return;
}
try {
for (File f : files) {
//send files code-Heavy code
} catch (SocketException e) {
//A JOptionPane exists here
e.printStackTrace();
} catch (Exception e) {
//A JOptionPane exists here
e.printStackTrace();
}
remove(pb);
add(panel);
statt.setText("Not connected");
server.setEnabled(true);
send.setEnabled(false);
ss.setText("Not Selected");
this.revalidate();
this.repaint();
Although,when an exception occurs and a JOptionPane is displayed,the progressbar is displayed until the dialog is closed and then returns to the normal UI.Can you help me out??Any and all answers are appreciated :)