title: Java falling matrix code (like the movie, continued)
body: <p>ok, so yesterday i posted a question in regards to creating a java jframe that simulates the matrix rain from the movies which i want to be just like this php example</p>
  
  <p><a href="http://mgccl.com/2007/03/30/simple-version-matrix-like-animated-dropping-character-effect-in-php" rel="nofollow">http://mgccl.com/2007/03/30/simple-version-matrix-like-animated-dropping-character-effect-in-php</a></p>
  
  <p>but i would like some help with two things,</p>
  
  <p>1st have more than one column falling at a time and
  2nd having the characters trailing behind each other</p>
  
  <p>this is my code so far</p>
  
  <pre><code>import java.awt.*;
  import java.util.*;
  import javax.swing.*;
  
  @SuppressWarnings("serial")
  public class MainFrame extends JFrame { 
  
  private static final int FONT_SIZE = 20;
  private static final int NUMBER_OF_REPEATS = 5;
  private static final String TEXT = new String("0123456789/*-+/&lt;&gt;?;:[]~!@#$%^&amp;*()+=abcdefghijklmnopqrstuvwxyz");
  private static JPanel panel = new JPanel(null);
  private static Random random = new Random();
  private static JLabel label[] = new JLabel[NUMBER_OF_REPEATS];
  
  public MainFrame() {        
      this.add(panel);
      panel.setBackground(Color.BLACK);
  }
  
  public void scroll() {
      for (int i = 0; i &lt; NUMBER_OF_REPEATS; i++) {
          int character_initial = random.nextInt(TEXT.length());
          int random_x = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;
          int colour = 255;
          label[i] = new JLabel(""+TEXT.charAt(character_initial));
          panel.add(label[i]);
          label[i].setFont(new Font("monospaced", Font.PLAIN, FONT_SIZE));
          label[i].setForeground(new Color(0, 255, 0));
  
          //change the text of the labels and their position
          for (int j = 0; j &lt; (panel.getHeight() / FONT_SIZE)*2; j++) {
              int character = random.nextInt(TEXT.length());
              label[i].setBounds(random_x*FONT_SIZE, j*(FONT_SIZE / 2), FONT_SIZE, FONT_SIZE);
              label[i].setText(""+TEXT.charAt(character));
  
              //if foreground colour &lt; 255 catch exception
              try {
                  //when text reaches a certain colour remove it
                  label[i].setForeground(new Color(0, 255-(j*5), 0));
                  colour = 255-(j*5);
                  if (colour &lt;= 80) {
                      panel.remove(label[i]);
                      repaint();
                      colour = 255;
                      j = (panel.getHeight() / FONT_SIZE)*2;
                  }
              } catch (Exception e) {}
  
              //pause between each character
              try {
                  Thread.sleep(75);
              } catch (Exception e) {}
          }
  
          //create an infinite loop
          if (i == NUMBER_OF_REPEATS - 1) {
              i = 0;
          }
      }
  }
  
  public static void main(String[] args) {
      MainFrame frame = new MainFrame();
      frame.setVisible(true);
      frame.setSize(600, 400);
      frame.setResizable(false);
      frame.setMinimumSize(new Dimension(300, 200));
      frame.setLocationRelativeTo(null);
      frame.setTitle("Matrix Code Emulator by Ricco");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
      frame.scroll();
  }
  }
  </code></pre>