title: make a special delay in gui of java
body: <p>I've made this code in java, i wanna make a delay after this part of code, but when i use delay or sleep codes the whole code sleeps for the delay time but i wanna see this back ground changes in gui and then make a delay!!! so what should i do?(I use swing gui)</p>
  
  <pre><code>for (int i = 0; i &lt; 8; i++) {
      for (int j = 0; j &lt; 8; j++) {
          if (matrisBazi[i][j] == 0) {
              jb[i][j].setBackground(Color.white);
          }
          if (matrisBazi[i][j] == 1) {
              jb[i][j].setBackground(Color.red);
          }
          if (matrisBazi[i][j] == 2) {
              jb[i][j].setBackground(Color.blue);
          }
      }
  }
  jb[i][j].addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent event) {   
      click(s);
      }
  });
  </code></pre>
  
  <p>my actionPerformed void is called before and its inside of click(); functions and is doing the process so how to add swing timer code to this void?!
  i think the timer doesn't work until the click(); finished.</p>