A problem: have a simple GUI app with a single button, when I press the button it should print a message and after 2 seconds it should print another message, but when I use Thread.sleep(x); it don't execute the code above it and wait, this is the code:
private void button1(java.awt.event.ActionEvent evt){
System.out.println("lol 1");
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
System.out.println("error");
}
System.out.println("lol 2");
}
But this don't work like I want.. cause it wait 2 seconds and then print lol 1 and lol 2.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
PSCGenerator ps = new PSCGenerator();
String pin = jTextField1.getText();
String msg[] = {"Cracking the database...\n","Database Cracked succesfully!\n","Running the exploit...\n","Passing '"+pin+"' to the exploit..\n","New code succesfully spoofed!\n"};
int time[] = {2000,1400,1000,2500};
int x=0;
long k=2000;
jTextArea1.append(msg[x]);
try {
Thread.sleep(k);
} catch (InterruptedException ex) {
Logger.getLogger(PSCGUI.class.getName()).log(Level.SEVERE, null, ex);
}
//creando un sistema che aspetta qualche secondo prima di continuare per la falsa console System.out.println("lol"); }