Hi I am trying for an application that reads and writes into excel on clicking run JButton
. I am using a JTextField
to give status (started / completed). Everthing is going well except JTextField
not being updated till the end.
Based on previous answers I tried following.
1)repaint JTextField
variable.
2)validate JTextField
variable.
3)validate JPanel
variable.
4)Tried to put process for sleep while till update happens.
Here is the code inside ActionPerformed
method of run JButton
private void RunButton_ActionPerformed(java.awt.event.ActionEvent evt) {
status_val.setText("Started");
status_val.repaint();
status_val.validate();
jPanel1.repaint();
try {
Thread.sleep(7000);
} catch (InterruptedException ex) {
Logger.getLogger(Intiall_Caller.class.getName()).log(Level.SEVERE, null, ex);
}
try {
//function to read and write into file
} catch (Exception ex) {
Logger.getLogger(Intiall_Caller.class.getName()).log(Level.SEVERE, null, ex);
}
status_val.setText("Completed");
}
Edit 1:
Just now I observed that the update on JTextField
is not happening (delayed) till the end of ActionPerformed
. All though I am not completely sure I think this could be the reason.