title: Jbutton flash between two background colors
body: <p><strong>My problem:</strong> Efficient way for the program to delay in my scenario.</p>
  
  <p><strong>My Scenario:</strong>
  I am making a quiz game for a short project, long story short. A question is answered when the user presses one of four Jbuttons having an answer on them. Then my quizengine class calls the paintbutton method showed here. After that it proceeds to call some other methods responsible for making the next question appear. Now what I want is to make the button change between two colors with decreasing time intervals. </p>
  
  <p><strong>What have I tried so far:</strong>
  First I placed a JoptionPane between the paintbutton method and the method that changes the interface to the next question just to see if the button would change color. It did successfully. Of course that wasn't my intention, I wanted just a time interval. 
  Then I tried using Thread.Sleep. Although the program would wait before changing to the next question, the color change was not visible.
  Finally I tried an implementation of the Timer thingy (probably not correctly) which although it changed the color the program went ahead and proceeded to the next question.</p>
  
  <p><strong>My want to be code</strong></p>
  
  <pre><code>  /* Paints the button pressed red or green
     *  Green if the anwser is correct red if 
     *  its false
     *
     * @param int bnr the number of the button
     * @param boolean corr true if correct false if false :D
     */
     public static void paintbutton(int bnr,boolean corr) { 
         for (int i=10;i&gt;1;i--){
          b[bnr-1].setBackground(null);     
          //wait for i*100 milliseconds
          b[bnr-1].setBackground(corr?Color.green:Color.red);          
         }
     }
  </code></pre>