I am trying to implement an image using the method below, so that when the send action is performed, the GIF image should show within a specified time(As implemented by the threadRunner pause method).
The problem is it doesn't show. And on testing, when I disable the stop() it appears at the same time as delIveryReport Textarea which shouldn't be. How do I solve this.
private void sendActionPerformed(java.awt.event.ActionEvent evt) {
threadRunner t = new threadRunner();
String fone = "";
SendSMS sms = new SendSMS();
String[] arMSISDN = msisdn.split(",");
for (int i = 0; i < arMSISDN.length; i++) {
fone = arMSISDN[i];
fone = fone.trim();
try {
Cursor cursor = new Cursor(Cursor.WAIT_CURSOR);
setCursor(cursor);
t.pause(loading);
sms.sendSMS(user, pass, fone, senderIDString, msgString);
} catch (Exception e) {
e.printStackTrace();
} finally {
Cursor normal = new Cursor(Cursor.DEFAULT_CURSOR);
setCursor(normal);
t.stop(loading);
deliveryReport.append(fone + ": " + sms.response + "\n");
}
}
// JOptionPane.showMessageDialog(rootPane, deliveryReport);
deliveryReport.setVisible(true);
jScrollPane2.setVisible(true);
redo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
redo.setForeground(new java.awt.Color(223, 90, 46));
redo.setText("Would you like to send another Message?");
yes.setEnabled(true);
no.setEnabled(true);
yes.setText("Yes");
no.setText("No");
back.setEnabled(false);
send.setEnabled(false);
}
THREADRUNNER
public void pause(JLabel label){
try {
Thread.sleep(5000);
label.setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(threadRunner.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void stop(JLabel l){
l.setVisible(false);
}