Programação Progressiva

Fórum para dúvidas dos sites: Programação Progressiva, Java Progressivo, C Progressivo


Você não está conectado. Conecte-se ou registre-se

efeito matrix em um rodapé de um jframe

Ver o tópico anterior Ver o tópico seguinte Ir em baixo  Mensagem [Página 1 de 1]

1 efeito matrix em um rodapé de um jframe em Sab Ago 03, 2013 6:53 pm

Código:

[font=Verdana, Arial, Helvetica, sans-serif]INICIO.[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]/*[/font]
[font=Verdana, Arial, Helvetica, sans-serif]* matrixadministracao.java[/font]
[font=Verdana, Arial, Helvetica, sans-serif]*[/font]
[font=Verdana, Arial, Helvetica, sans-serif]* Created on 2 de Agosto de 2013, 06:29[/font]
[font=Verdana, Arial, Helvetica, sans-serif]*/[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]/**[/font]
[font=Verdana, Arial, Helvetica, sans-serif]*[/font]
[font=Verdana, Arial, Helvetica, sans-serif]* @author  Junior[/font]
[font=Verdana, Arial, Helvetica, sans-serif]*/[/font]
[font=Verdana, Arial, Helvetica, sans-serif]public class matrixadministracao extends javax.swing.JFrame {[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]   /** Creates new form matrixadministracao */[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   public matrixadministracao() {[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       initComponents();[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   }[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]   /** This method is called from within the constructor to[/font]
[font=Verdana, Arial, Helvetica, sans-serif]    * initialize the form.[/font]
[font=Verdana, Arial, Helvetica, sans-serif]    * WARNING: Do NOT modify this code. The content of this method is[/font]
[font=Verdana, Arial, Helvetica, sans-serif]    * always regenerated by the Form Editor.[/font]
[font=Verdana, Arial, Helvetica, sans-serif]    */[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   @SuppressWarnings("unchecked")[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   private void initComponents() {[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       getContentPane().setLayout(layout);[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       layout.setHorizontalGroup([/font]
[font=Verdana, Arial, Helvetica, sans-serif]           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)[/font]
[font=Verdana, Arial, Helvetica, sans-serif]           .addGap(0, 400, Short.MAX_VALUE)[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       );[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       layout.setVerticalGroup([/font]
[font=Verdana, Arial, Helvetica, sans-serif]           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)[/font]
[font=Verdana, Arial, Helvetica, sans-serif]           .addGap(0, 300, Short.MAX_VALUE)[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       );[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]       pack();[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   }// </editor-fold>                        [/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]   /**[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   * @param args the command line arguments[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   */[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   public static void main(String args[]) {[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       java.awt.EventQueue.invokeLater(new Runnable() {[/font]
[font=Verdana, Arial, Helvetica, sans-serif]           public void run() {[/font]
[font=Verdana, Arial, Helvetica, sans-serif]               new matrixadministracao().setVisible(true);[/font]
[font=Verdana, Arial, Helvetica, sans-serif]           }[/font]
[font=Verdana, Arial, Helvetica, sans-serif]       });[/font]
[font=Verdana, Arial, Helvetica, sans-serif]   }[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]   // Variables declaration - do not modify                    [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   // End of variables declaration                  [/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]}[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]CÓDIGO[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
[font=Verdana, Arial, Helvetica, sans-serif]import java.awt.*;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]import java.util.*;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]import javax.swing.*;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif] [/font]
[font=Verdana, Arial, Helvetica, sans-serif]@SuppressWarnings("serial")  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]public class matrixRain extends JFrame {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static final int FONT_SIZE = 20;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static final int NUMBER_OF_REPEATS = 5;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static final String TEXT = new String("あ     た        [/font]
[font=Verdana, Arial, Helvetica, sans-serif]ア        カ                                  サ    ザ      ジ    [/font]
[font=Verdana, Arial, Helvetica, sans-serif]ズ       ゼ       ゾ           シ    ス      セ   ソ    キ   ク   ケ   コ   イ  ウ   エ    オ   ジャ な");  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static JPanel panel = new JPanel(null);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static Random random = new Random();  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]private static JLabel label[] = new JLabel[NUMBER_OF_REPEATS];  [/font]
[font=Verdana, Arial, Helvetica, sans-serif] [/font]
[font=Verdana, Arial, Helvetica, sans-serif]public matrixRain() {          [/font]
[font=Verdana, Arial, Helvetica, sans-serif]  this.add(panel);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]  panel.setBackground(Color.BLACK);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]}  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]public void scroll() {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     //array to hold x coordinates for the labels  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   int[] random_x = new int[NUMBER_OF_REPEATS];  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   //create an infinite loop  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   while (true) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       //initialise all the labels to random characters  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       for (int i = 0; i < NUMBER_OF_REPEATS; i++) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]        int character_initial = random.nextInt(TEXT.length());  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]         random_x[i] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]         label[i] = new JLabel("" + TEXT.charAt(character_initial));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]         panel.add(label[i]);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]         label[i].setFont(new Font("monospaced", Font.PLAIN, FONT_SIZE));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       label[i].setForeground(new Color(0, 255, 0));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   // change the text of the labels and their position  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]   for (int j = 0; j < (panel.getHeight() / FONT_SIZE) * 2; j++) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       int character = random.nextInt(TEXT.length());  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       //move each character  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]      for (int i = 0; i < NUMBER_OF_REPEATS; i++) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]           label[i].setBounds(random_x[i] * FONT_SIZE, j * (FONT_SIZE / 2), FONT_SIZE, FONT_SIZE);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]           label[i].setText("" + TEXT.charAt(character));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]           label[i].setForeground(new Color(0, 255 - (j * 5), 0));      [/font]
[font=Verdana, Arial, Helvetica, sans-serif]          for (int k = 0; k < NUMBER_OF_REPEATS; k++) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]              int character_initial = random.nextInt(TEXT.length());  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]              random_x[k] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]               label[k] = new JLabel("" + TEXT.charAt(character_initial));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]               panel.add(label[k]);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]               label[k].setFont(new Font("monospaced", Font.PLAIN, FONT_SIZE));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]              label[k].setForeground(new Color(0, 255, 0));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]              Color colour = label[k].getForeground();  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]              if (colour.getGreen() <= 80) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]                   panel.remove(label[k]);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]                  k = (panel.getHeight() / FONT_SIZE) * 2;  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]               }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]           }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       // pause between each character  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       try {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]           Thread.sleep(15);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       } catch (Exception e) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif] }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]       }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif] public static void main(String[] args) {  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     matrixRain frame = new matrixRain();  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     frame.setVisible(true);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     frame.setSize(600, 400);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    frame.setResizable(false);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    frame.setMinimumSize(new Dimension(300, 200));  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     frame.setLocationRelativeTo(null);  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    frame.setTitle("Matrix Code Emulator by Ricco");  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    [/font]
[font=Verdana, Arial, Helvetica, sans-serif]     frame.scroll();  [/font]
[font=Verdana, Arial, Helvetica, sans-serif] }  [/font]
[font=Verdana, Arial, Helvetica, sans-serif]}[/font]
[font=Verdana, Arial, Helvetica, sans-serif][/font]
 

Ver perfil do usuário

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo  Mensagem [Página 1 de 1]

Permissão deste fórum:
Você não pode responder aos tópicos neste fórum