title: changing images in jLabel after certain intervals
body: <p>I had to make a sort of animation thing in netbeans gui. So I was studying about swing timer on the internet and from what i found i worte a method which will change images in jLabel after certain time periods.</p>
  
  <pre><code>public void animation() throws InterruptedException {
      ActionListener taskPerformer = new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
              //...Perform a task...
              t++;
              System.out.printf("Reading SMTP Info. %d\n",t);
              if(t%2==1){
                  jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/oncsreen_keypad/a.jpg")));
              }
              else{
                  jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/oncsreen_keypad/b.jpg")));
              }
          }
      };
      Timer timer = new Timer( 1000 , taskPerformer);
      //timer.setRepeats(false);
      timer.start();
  
      Thread.sleep(5000);
  }
  </code></pre>
  
  <p>this method is called nowhere. But if the System.out.printf works then changing image in jLabel should also work. But actually in the run those lines are having no effect on the jLabel.</p>
  
  <p>So what should be the right approach.</p>