I wanted to make a Java program with Numberfields and a button. When you click the button it waits and the time that was put in the Numberfield.The Integers work fine, but the function does not work.
Here is the code:
public void jButton1_ActionPerformed(ActionEvent evt) { sekunden = Integer.parseInt(jNumberField3.getText()); minuten = Integer.parseInt(jNumberField2.getText()); stunden = Integer.parseInt(jNumberField1.getText()); zeit = sekunden + minuten*60 + stunden*60*60;//berechnet die zeit in sekunden TimeUnit.SECONDS.sleep(zeit);//here is the error System.out.println("zeit"); } // end of jButton1_ActionPerformed The error message looks like this:
ES.java:78:27: error: unreported exception InterruptedException; must be caught or declared to be thrown TimeUnit.SECONDS.sleep(zeit);