Unable to repaint the window using the timer
<p>I have a button that has the initial starting position. The Y-axis of the button are to be constant throughout, but the x-axis are to change every second. The timer increments the value of x every second by 10, and repaints the window. The value of x seems to increment just fine but the components aren't updated even when the repaint and validate method are invoked.</p>

<pre><code>import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.Timer;

public class TedmadLogo {

   JWindow myWindow = new JWindow();

   Container container = myWindow.getContentPane();

   JPanel panel = new JPanel();
   ImageIcon image = new ImageIcon("bg.jpg");
   ImageIcon image2 = new ImageIcon("bg2.jpg");
   JButton button1 = new JButton("Button");
   JLabel bg = new JLabel(image);
   JLabel bg2 = new JLabel(image2);
   int x = 50;

   ActionListener taskPerformer = new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
         x += 10;
         myWindow.getContentPane().validate();
         myWindow.getContentPane().repaint();
         System.out.println(x);
         timer.restart();
      }
   };

   Timer timer = new Timer(1000, taskPerformer);

   public TedmadLogo() {

      myWindow.setLayout(null);
      panel.setLayout(null);
      myWindow.setSize(600, 300);

      myWindow.setVisible(true);
      myWindow.setLocationRelativeTo(null);

      container.add(panel);
      panel.setBounds(0, 0, 600, 300);

      panel.add(button1);
      panel.add(bg2);
      panel.add(bg);
      button1.setBounds(x, 150, 30, 30);
      bg2.setBounds(150, 0, 600, 300);
      bg.setBounds(-150, 0, 600, 300);
   }

   public static void main(String[] args) {
      TedmadLogo logo = new TedmadLogo();
      logo.timer.start();
   }
}
</code></pre>
