0

これは、コードの実行を 5 秒遅らせるために Java を使用して記述されたコードです。しかし、それは機能していません。「this.jLabel2.setText("TDK");」のいずれか ステートメントが機能していません。誰でもこの問題を解決するのを手伝ってくれませんか。

 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    this.jLabel2.setText("TDK");
    boolean result=false;
    result=stop();
    if(result)
    {
      this.jLabel1.setText("MDK");
    }
}
public boolean stop()
{
    String current= new java.text.SimpleDateFormat("hh:mm"
            + ":ss").format(new java.util.Date(System.currentTimeMillis()));
    String future=new java.text.SimpleDateFormat("hh:mm"
            + ":ss").format(new java.util.Date(System.currentTimeMillis()+5000));   

    while(!(current.equals(future)))
    {
       current= new java.text.SimpleDateFormat("hh:mm"
               + ":ss").format(new java.util.Date(System.currentTimeMillis()));  
    }

      return true;
}
4

2 に答える 2

1

を に設定して使用javax.swing.Timerします。setRepeatsfalse

于 2013-08-28T18:49:30.267 に答える