My Open button in my DefaultForm JFrame has this Listener
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser chooser = new JFileChooser();
File file = null;
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
System.out.println(file.getName());
}
try {
Scanner sc = new Scanner(file);
while (sc.hasNext()) {
String[] s = sc.nextLine().split(",");
digitalPanel.tempTextField.setText(s[0]);
digitalPanel.airTextField.setText(s[1]);
digitalPanel.insoTextField.setText(s[2]);
Thread.sleep(100);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(DefaultForm.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(DefaultForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
digitalPanel is a panel in the DefaultForm.
I want to display data read from a file but with an amount delay time.
It will work if i remove Thread.sleep(1000);
But it gets stuck when i put Thread.sleep(1000);
in the while loop
Got any ideas in this case ?
Your help will be appreciated.