title: How to alternate speed using an array of integers for javax swing timer
body: <p>I am attempting to simulate rain falling using fixed line lengths with randomly generated x coordinates. I have got the random x coordinates working but I want lines to have different falling speeds as well once they are repainted onto the window. I am using the javax swing timer and the java Random to generate integers to pass into my "speed" array as indexes. The speed however does not change. It remains the same and is way too fast. </p>
  
  <pre><code>public class rain extends JPanel implements ActionListener {
  int i = 0;
  int[] speed = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
  double[] x = {10, 202, 330, 140, 250, 160, 470, 180, 290, 510};
  double y1 = 10, y2 = 20;
  double down = 1;
  Random random = new Random();
  //Timer t = new Timer(speed[i], this);
  
  
  
  public void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D l = (Graphics2D) g;
          Line2D line = new Line2D.Double(x[i], y1, x[i], y2);
          l.setColor(Color.blue);
          l.draw(line);
          Timer t = new Timer(speed[i], this);
          t.start();
  }
  
  
  public void actionPerformed(ActionEvent e) {        
          if (y2 &lt; 380) {
              y1 += down; 
              y2 += down;
          }else{
              y1 = 10;
              y2 = 20;
              i = random.nextInt(10);
  
          }
      repaint();
  
  }
  </code></pre>