Bom dia Professores!
como diz o tópico, desejo colocar o efeito matrix em um rodapé em um jframe. só que tenho 2 códigos que precisam ser examinados, compilados, testados para saber se há algum problema. também desejo saber se vcs podem corrigi-los e me enviar. não sei como dispo-los, preciso que madem um recadinho se alguém poderá me ajudar, se poderem o façam segue abaixo o primeiro e o segundo código por favor transfome-os em um só. agradeço obrigado. por favor se não forem me ajudar, não me mandem mensagens de crítica sou consciente do que quero e sei o que estou fazendo.
Primeiro código
package Administracao;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
* Classe
*
* @author Olívio Júnior
*/
public class MeuPrimeiroFrame extends JFrame {
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu10;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;
private javax.swing.JMenu jMenu7;
private javax.swing.JMenu jMenu8;
private javax.swing.JMenu jMenu9;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
public static void main (String[] args){
new MeuPrimeiroFrame().setVisible(true);
}
public MeuPrimeiroFrame(){
initComponents();
}
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
jMenu9 = new javax.swing.JMenu();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenu10 = new javax.swing.JMenu();
jMenuItem12 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenu5 = new javax.swing.JMenu();
jMenu6 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu();
jMenu7 = new javax.swing.JMenu();
jMenu8 = new javax.swing.JMenu();
jMenu9.setText("Menu");
jMenuItem11.setText("Item");
jMenu9.add(jMenuItem11);
jMenuItem10.setText("Item");
jMenu9.add(jMenuItem10);
jMenuItem9.setText("Item");
jMenu9.add(jMenuItem9);
jMenuItem8.setText("Item");
jMenu9.add(jMenuItem8);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Administração");
setFont(new java.awt.Font("Arial Narrow", 1, 12)); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE));
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE));
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/ativa mes 02.PNG"))); // NOI18N
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jButton1, org.jdesktop.beansbinding.ELProperty.create("${actionCommand}"), jButton1, org.jdesktop.beansbinding.BeanProperty.create("selected"));
bindingGroup.addBinding(binding);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "Buu");
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/eventos.PNG"))); // NOI18N
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/empresas.PNG"))); // NOI18N
jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/encerra mes 02.PNG"))); // NOI18N
jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/escritorio.PNG"))); // NOI18N
jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/contas a pagar.PNG"))); // NOI18N
jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siscontábil/Imagenspng/contas a receber.PNG"))); // NOI18N
jMenu1.setBackground(new java.awt.Color(153, 153, 153));
jMenu1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu1.setText("Arquivo");
jMenu1.setFont(new java.awt.Font("Arial Narrow", 1, 12));
jMenuItem1.setText("Item");
jMenu1.add(jMenuItem1);
jMenuItem2.setText("Item");
jMenu1.add(jMenuItem2);
jMenuItem3.setText("Item");
jMenu1.add(jMenuItem3);
jMenuItem4.setText("Item");
jMenu1.add(jMenuItem4);
jMenuItem5.setText("Item");
jMenu1.add(jMenuItem5);
jMenuItem6.setText("Item");
jMenu1.add(jMenuItem6);
jMenu10.setText("Menu");
jMenuItem12.setText("Item");
jMenu10.add(jMenuItem12);
jMenuItem13.setText("Item");
jMenu10.add(jMenuItem13);
jMenuItem14.setText("Item");
jMenu10.add(jMenuItem14);
jMenuItem15.setText("Item");
jMenu10.add(jMenuItem15);
jMenu1.add(jMenu10);
jMenuItem7.setText("Item");
jMenu1.add(jMenuItem7);
jMenuBar1.add(jMenu1);
jMenu3.setBackground(new java.awt.Color(153, 153, 153));
jMenu3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu3.setText("Relatórios");
jMenu3.setFont(new java.awt.Font("Arial Narrow", 1, 12));
jMenuBar1.add(jMenu3);
jMenu5.setBackground(new java.awt.Color(153, 153, 153));
jMenu5.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu5.setText("Tabelas");
jMenu5.setFont(new java.awt.Font("Arial Narrow", 1, 12));
jMenuBar1.add(jMenu5);
jMenu6.setBackground(new java.awt.Color(153, 153, 153));
jMenu6.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu6.setText("Diversos");
jMenu6.setFont(new java.awt.Font("Arial Narrow", 1, 14));
jMenuBar1.add(jMenu6);
jMenu4.setBackground(new java.awt.Color(153, 153, 153));
jMenu4.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu4.setText("Utilitários");
jMenu4.setFont(new java.awt.Font("Arial Narrow", 1, 14));
jMenuBar1.add(jMenu4);
jMenu7.setBackground(new java.awt.Color(153, 153, 153));
jMenu7.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
jMenu7.setText("Clássico");
jMenu7.setFont(new java.awt.Font("Arial Narrow", 1, 14));
jMenuBar1.add(jMenu7);
jMenu8.setBackground(new java.awt.Color(153, 153, 153));
jMenu8.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(153, 153, 153)));
jMenu8.setText("Tributos");
jMenu8.setFont(new java.awt.Font("Arial Narrow", 1, 14));
jMenuBar1.add(jMenu8);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton7, 0, 0, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(534, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(328, Short.MAX_VALUE)
.addComponent(jButton3)
.addGap(5130, 5130, 5130))
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 57, Short.MAX_VALUE)
.addGap(8, 8, 8)
.addComponent(jButton7)
.addGap(5110, 5110, 5110)));
bindingGroup.bind();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width - 650) / 2, (screenSize.height - 580) / 2, 650, 580);
}
}
Segundo código
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Juniorpúblic strictfp classe Matrix
{
public static void resolver (Final double A [] [], double final, Y [],
duplo X [])
{
/ / Resolver equações lineares reais para X, onde Y = A * X
/ / Método: Gauss-Jordan eliminação usando máximo pivot
/ / Uso: Matrix.solve (A, Y, X);
/ / Traduzido para java por: Jon Squire, 26 mar 2003
/ / Primeiro escrito por Jon Squire dezembro 1959 para IBM 650, traduzido para o
/ / Outras línguas, por exemplo Fortran convertido para Ada convertido para C
/ / Convertido em java
int n = a.length;
int m = n +1;
B double [] [] = new double [n] [m]; matriz / / trabalhar
int row [] = new int [n]; indicies / / linha intercâmbio
hold int, I_pivot / / pivô indicies
duplo pivot, valor elemento / / pivot
abs_pivot duplo;
if (A [0] = comprimento n |.! | Y.length = n |! |! x.length = n)
{
System.out.println ("Erro na Matrix.solve tamanhos matriz inconsistentes.");
}
/ / Build trabalho estrutura de dados
for (int i = 0; i <n, i + +)
{
para (int j = 0, j <n, j + +)
{
B [i] [j] = A [i] [j];
}
B [i] [n] = Y [i];
}
/ / Criar vetores de intercâmbio de linha
for (int k = 0; k <n, k + +)
{
linha [k] = k;
}
/ / Começam circuito principal redução
for (int k = 0; k <n, k + +)
{
/ / Encontra maior elemento de pivot
pivot = B [linha [k]] [k];
abs_pivot = Math.abs (pivô);
I_pivot = k;
for (int i = k, i <n, i + +)
{
if (Math.abs (B [linha [i]] [k])> abs_pivot)
{
I_pivot = i;
pivot = B [linha [i]] [k];
abs_pivot = Math.abs (pivô);
}
}
/ / Tem articulação, intercâmbio indicies de linha
segurar = linha [k];
linha [k] = linha [I_pivot];
row [I_pivot] = espera;
/ / Verificar se há perto singular
if (abs_pivot <1.0E-10)
{
for (int j = k +1, j <n +1, j + +)
{
B [linha [k]] [j] = 0,0;
}
System.out.println ("linha redundante (singular)" + row [k]);
} / / Singular, apagar a linha
outro
{
/ / Reduzir cerca de pivot
for (int j = k +1, j <n +1, j + +)
{
B [linha [k]] [j] = B [linha [k]] [j] / B [linha [k]] [k];
}
Ciclo de redução / / interior
for (int i = 0; i <n, i + +)
{
if (i! = k)
{
for (int j = k +1, j <n +1, j + +)
{
B [linha [i]] [j] = B [linha [i]] [j] - B [linha [i]] [k] * B [linha [k]] [j];
}
}
}
}
/ / Terminou redução interna
}
/ / Fim do laço principal redução
/ / Build X para o retorno, ordenar linhas
for (int i = 0; i <n, i + +)
{
X [i] = B [linha [i]] [n];
}
} / / Fim resolver
vazio public static final invertido (double A [] [])
{
int n = a.length;
int row [] = new int [n];
int col [] = new int [n];
double temp [] = new double [n];
hold int, I_pivot, J_pivot;
duplo pivot, abs_pivot;
if (a [0]. comprimento! = n)
{
System.out.println ("Erro na Matrix.invert tamanhos matriz inconsistentes.");
}
/ / Define a linha e vetores de intercâmbio coluna
for (int k = 0; k <n, k + +)
{
linha [k] = k;
col [k] = k;
}
/ / Começam circuito principal redução
for (int k = 0; k <n, k + +)
{
/ / Encontra maior elemento de pivot
pivot = A [linha [k]] [col [k]];
I_pivot = k;
J_pivot = k;
for (int i = k, i <n, i + +)
{
for (j = int k, j <n, j + +)
{
abs_pivot = Math.abs (pivô);
if (Math.abs (A [linha [i]] [col [j]])> abs_pivot)
{
I_pivot = i;
J_pivot = j;
pivot = A [linha [i]] [col [j]];
}
}
}
if (Math.abs (pivô) <1.0E-10)
{
System.out.println ("Matrix é singular!");
voltar;
}
segurar = linha [k];
linha [k] = linha [I_pivot];
row [I_pivot] = espera;
segurar = col [k];
col [k] = col [J_pivot];
col [J_pivot] = espera;
/ / Reduzir cerca de pivot
A [linha [k]] [col [k]] = 1,0 / pivô;
para (int j = 0, j <n, j + +)
{
if (j! = k)
{
A [linha [k]] [col [j]] = A [linha [k]] [col [j]] * A [linha [k]] [col [k]];
}
}
Ciclo de redução / / interior
for (int i = 0; i <n, i + +)
{
if (k! = i)
{
para (int j = 0, j <n, j + +)
{
if (k! = j)
{
A [linha [i]] [col [j]] = A [linha [i]] [col [j]] - A [linha [i]] [col [k]] *
A [linha [k]] [col [j]];
}
}
A [linha [i]] [col [k]] = - A [linha [i]] [col [k]] * A [linha [k]] [col [k]];
}
}
}
/ / Fim do laço principal redução
/ / Decodificar linhas
para (int j = 0, j <n, j + +)
{
for (int i = 0; i <n, i + +)
{
temp [col [i]] = A [linha [i]] [j];
}
for (int i = 0; i <n, i + +)
{
A [i] [j] = temp [i];
}
}
/ / Desembaralhar colunas
for (int i = 0; i <n, i + +)
{
para (int j = 0, j <n, j + +)
{
temp [linha [j]] = A [i] [col [j]];
}
para (int j = 0, j <n, j + +)
{
A [i] [j] = temp [j];
}
}
} / / Fim invertido
estática determinante double public final (duplo final de A [] [])
{
int n = a.length;
duplo D = 1.0 / / determinante
B double [] [] = new double [n] [n]; matriz / / trabalhar
int row [] = new int [n]; indicies / / linha intercâmbio
hold int, I_pivot / / pivô indicies
duplo pivot, valor elemento / / pivot
abs_pivot duplo;
if (a [0]. comprimento! = n)
{
System.out.println ("Erro na Matrix.determinant, tamanhos de matriz inconsistentes.");
}
/ / Construir matriz de trabalho
for (int i = 0; i <n, i + +)
para (int j = 0, j <n, j + +)
B [i] [j] = A [i] [j];
/ / Criar vetores de intercâmbio de linha
for (int k = 0; k <n, k + +)
{
linha [k] = k;
}
/ / Começam circuito principal redução
for (int k = 0; k <n-1, k + +)
{
/ / Encontra maior elemento de pivot
pivot = B [linha [k]] [k];
abs_pivot = Math.abs (pivô);
I_pivot = k;
for (int i = k, i <n, i + +)
{
if (Math.abs (B [linha [i]] [k])> abs_pivot)
{
I_pivot = i;
pivot = B [linha [i]] [k];
abs_pivot = Math.abs (pivô);
}
}
/ / Tem articulação, intercâmbio indicies de linha
if (I_pivot! = k)
{
segurar = linha [k];
linha [k] = linha [I_pivot];
row [I_pivot] = espera;
= D - D;
}
/ / Verificar se há perto singular
if (abs_pivot <1.0E-10)
{
retornar 0,0;
}
outro
{
D = D * pivô;
/ / Reduzir cerca de pivot
for (int j = k +1, j <n, j + +)
{
B [linha [k]] [j] = B [linha [k]] [j] / B [linha [k]] [k];
}
Ciclo de redução / / interior
for (int i = 0; i <n, i + +)
{
if (i! = k)
{
for (int j = k +1, j <n, j + +)
{
B [linha [i]] [j] = B [linha [i]] [j] - B [linha [i]] [k] * B [linha [k]] [j];
}
}
}
}
/ / Terminou redução interna
}
/ / Fim do laço principal redução
voltar D * B [row [n-1]] [n-1];
Determinante} / / fim
estáticos autovalores nulos finais públicos (duplo final de A [] [],
V double [] [], double Y [])
{
/ / Cíclica Jacobi método de encontrar eigenvalues iterativo
/ / Anunciados para o real simétrica
int n = a.length;
duplo AA [] [] = new double [n] [n];
duplo norma;
double c [] = new double [1];
double s [] = new double [1];
if (A [0] = comprimento n |.! | V.length = n |! | V [0] = comprimento n |.! |! Y.length = n)
{
System.out.println ("Erro na Matrix.eigenvalues, tamanhos de matriz inconsistentes.");
}
c [0] = 1,0;
s [0] = 0,0;
for (int i = 0; i <n, i + +) / / start V como matriz de identidade
{
for (int j = 0; j <n, j + +) V [i] [j] = 0,0;
V [i] [i] = 1,0;
}
cópia (A, AA);
for (int k = 0; k <n, k + +)
{
norma = norm4 (AA);
for (int i = 0; i <n-1, i + +)
{
for (int j = i +1, j <n, j + +)
{
schur2 (AA, I, J, c, s);
mat44 (i, j, C, S, AA V);
}
} / / Fim uma iteração
}
norma = norm4 (AA) / / qualidade final verificar se desejado
for (int i = 0; i <n, i + +) / / cópia autovalores de volta ao chamador
Y [i] = AA [i] [i];
} / / Fim eigenvalues
public static eigenCheck vazio final (duplo final de A [] [], último duplo V [] [],
duplo Y [])
{
/ / Verifica A * X = X lambda lambda = Y [i] X = V [i]
int n = a.length;
duplo X [] = new double [n];
double Z [] = new double [n];
duplo T [] = new double [n];
duplo norma;
if (A [0] = comprimento n |.! | V.length = n |! | V [0] = comprimento n |.! |! Y.length = n)
{
System.out.println ("Erro na Matrix.eigenCheck, tamanhos de matriz inconsistentes.");
}
for (int i = 0; i <n, i + +)
{
para (int j = 0, j <n, j + +)
{
X [j] = V [j] [i];
}
multiplicar (A, X, T);
para (int j = 0, j <n, j + +)
{
Z [j] = T [j]-Y [i] * X [j];
}
norma = Norm2 (Z);
System.out.println ("verificar se há perto de zero norma de Z [" + i + "] =" + Z [i]);
}
EigenCheck} / / fim
static void schur2 (duplo final de A [] [], final int p, final int q,
double c [], double s [])
{
duplo tau;
double t;
if (A [0] = comprimento a.length |.! | c.length = 1 |! |! s.length = 1)
{
System.out.println ("Erro na schur2 de Jacobi, tamanhos de matriz inconsistentes.");
}
if (A [p] [q]! = 0,0)
{
tau = (A [q] [q]-A [p] [p]) / (2.0 * A [p] [q]);
if (tau> = 0,0)
t = 1,0 / (tau Math.sqrt + (1,0 * + tau tau));
outro
t = -1.0 / ((tau) + Math.sqrt (1,0 + tau tau *));
c [0] = 1.0/Math.sqrt (1,0 + t * t);
s [0] = t * c [0];
}
outro
{
c [0] = 1,0;
s [0] = 0,0;
}
} / / Fim schur2
static void mat22 (duplo final, c [], final de double s [], final de double A [] [],
B double [] [])
{
if (a.length = 2 |! | A [0] comprimento = 2 |.! | B.length = 2 |! |.! B [0] length = 2)
{
System.out.println ("Erro na mat22 de Jacobi, não tanto 2 por 2");
}
duplo T [] [] = new double [2] [2];
T [0] [0] = c [0] * A [0] [0] - s [0] * A [0] [1];
T [0] [1] = s [0] * A [0] [0] + C [0] * A [0] [1];
T [1] [0] = c [0] * A [1] [0] - s [0] * A [1] [1];
T [1] [1] = s [0] *-A [1] [0] + C [0] *-A [1] [1];
B [0] [0] = c [0] * T [0] [0] - s [0] * T [1] [0];
B [0] [1] = c [0] * T [0] [1] - s [0] * T [1] [1];
B [1] [0] = s [0] * T [0] [0] + c [0] * T [1] [0];
B [1] [1] = s [0] * T [0] [1] + C [0] * T [1] [1];
} / / Fim mat2
static void mat44 (final int p, q final int, double final, c [], double final de s [],
A última double [] [], double V [] [])
{
int n = a.length;
B double [] [] = new double [n] [n];
duplo J [] [] = new double [n] [n];
if (s.length = 1 |! |! c.length = 1)
{
System.out.println ("Erro na mat44 de Jacobi, s ou c não comprimento 1");
}
if (A [0] = comprimento n |.! | V.length = n |! |.! V [0] = comprimento n)
{
System.out.println ("Erro na mat44 de Jacobi, A ou V não mesmo e quadrado");
}
for (int i = 0; i <n, i + +)
{
para (int j = 0, j <n, j + +)
{
J [i] [j] = 0,0;
}
J [i] [i] = 1,0;
}
J [p] [p] = c [0]; / * J transpor * /
J [p] [q] =-s [0];
J [q] [q] = c [0];
J [q] [p] = s [0];
multiplicar (J, A, B);
J [p] [q] = s [0];
J [q] [p] =-s [0];
multiplicar (B, J, A);
multiplicar (V, J, B);
cópia (B, V);
} / / Fim mat44
norm4 dupla estática (Final double A [] []) / / para Jacobi
{
int n = a.length;
int n = A [0] comprimento.;
duplo nrm = 0,0;
if (n! = NR)
{
System.out.println ("Erro na norm4, não quadrada A [" + n + "] [" + n + "]");
}
for (int i = 0; i <n-1, i + +)
{
for (int j = i +1, j <n, j + +)
{
nrm = nrm + Math.abs (A [i] [j]) + Math.abs (A [j] [i]);
}
}
voltar NRM / (n * nn);
} / / Fim norm4
public static multiplicam vazio final (duplo final de A [] [], última dupla B [] [],
duplo C [] [])
{
int ni = a.length;
int nk = A [0] comprimento.;
int nj = B [0] comprimento.;
if (B.length = nk |! | c.length = ni |! |.! C [0] = comprimento nj)
{
System.out.println ("Erro na Matrix.multiply, tamanhos incompatíveis");
}
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +)
{
C [i] [j] = 0,0;
for (int k = 0; k <nk; k + +)
C [i] [j] = C [i] [j] + A [i] [k] * B [k] [j];
}
Multiplicam} / / fim
public static void adiciona final (duplo final de A [] [], double final de B [] [],
duplo C [] [])
{
int ni = a.length;
int nj = A [0] comprimento.;
if (B.length = ni |! | c.length = ni |! | B [0] = comprimento nj |.! |.! C [0] = comprimento nj)
{
System.out.println ("Erro na Matrix.add tamanhos incompatíveis");
}
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +)
C [i] [j] = A [i] [j] + B [i] [j];
} / / Fim adicionar
public static subtrair vazio final (final de double A [] [], última dupla B [] [], double C [] [])
{
int ni = a.length;
int nj = A [0] comprimento.;
if (B.length = ni |! | c.length = ni |! | B [0] = comprimento nj |.! |.! C [0] = comprimento nj)
{
System.out.println ("Erro na Matrix.subtract, tamanhos incompatíveis");
}
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +)
C [i] [j] = A [i] [j] - B [i] [j];
Subtração} / / fim
public static final double Norm1 (duplo final de A [] [])
{
dobrar norma = 0,0;
duplo colSum;
int ni = a.length;
int nj = A [0] comprimento.;
for (int j = 0; j <nj, j + +)
{
colSum = 0,0;
for (int i = 0; i <ni, i + +)
colSum = colSum + Math.abs (A [i] [j]);
norma = Math.max (norma, colSum);
}
voltar norma;
} / / Fim Norm1
public static final double normInf (duplo final de A [] [])
{
dobrar norma = 0,0;
duplo rowSum;
int ni = a.length;
int nj = A [0] comprimento.;
for (int i = 0; i <ni, i + +)
{
rowSum = 0,0;
for (int j = 0; j <nj, j + +)
rowSum = rowSum + Math.abs (A [i] [j]);
norma = Math.max (norma, rowSum);
}
voltar norma;
NormInf} / / fim
identidade vazio public static final (o dobro A [] [])
{
int n = a.length;
if (a [0]. comprimento! = n)
{
System.out.println ("Erro na Matrix.Identity, não quadrado");
}
for (int i = 0; i <n, i + +)
{
for (int j = 0; j <n, j + +) A [i] [j] = 0,0;
A [i] [i] = 1,0;
}
Identidade} / / fim
public void static final zero (duplo A [] [])
{
int ni = a.length;
int nj = A [0] comprimento.;
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +) A [i] [j] = 0,0;
} / / Fim de zero
public static final double normFro (duplo final de A [] [])
{
dobrar norma = 0,0;
int n = a.length;
for (int i = 0; i <n, i + +)
para (int j = 0, j <n, j + +)
norma = norma + A [i] [j] * A [i] [j];
voltar Math.sqrt (norma);
} / / Fim normFro
public static double Norm2 final (final de double A [] [])
{
double r = 0,0; / / maior autovalor
int n = a.length;
B double [] [] = new double [n] [n];
V double [] [] = new double [n] [n];
duplo BI [] = new double [n];
for (int i = 0; i <n, i + +) / / B = A ^ T * A
{
para (int j = 0, j <n, j + +)
{
B [i] [j] = 0,0;
for (int k = 0; k <n, k + +)
B [i] [j] = B [i] [j] + A [k] [i] * A [k] [j];
}
}
eigenvalues (B, V, BI);
for (int i = 0; i <n, i + +) r = Math.max (r, BI [i]);
voltar Math.sqrt (r);
} / / Fim Norm2
public static cópia final void (duplo final de A [] [], double B [] [])
{
int ni = a.length;
int nj = A [0] comprimento.;
if (B.length = ni |! |.! B [0] = comprimento nj)
{
System.out.println ("Erro na Matrix.copy," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +)
B [i] [j] = A [i] [j];
Cópia} / / fim
public static final boolean equals (final de double A [] [], double final de B [] [])
{
int ni = a.length;
int nj = A [0] comprimento.;
boolean mesmo = true;
if (B.length = ni |! |.! B [0] = comprimento nj)
{
System.out.println ("Erro na Matrix.equals," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <ni, i + +)
for (int j = 0; j <nj, j + +)
mesmo = mesmos && (A [i] [j] == B [i] [j]);
voltar mesmo;
} / / Fim é igual
público de impressão vazio static final (o dobro A [] [])
{
int N = a.length;
for (int i = 0; i <N; i + +)
para (int j = 0, j <N; j + +)
System.out.println ("A [" + i + "] [" + j + "] =" + A [i] [j]);
} / / Fim de impressão
public static multiplicam vazio final (duplo A [] [], double B [], double C [])
{
int n = a.length;
for (int i = 0; i <n, i + +) {
C [i] = 0,0;
para (int j = 0, j <n, j + +) {
C [i] = C [i] + A [i] [j] * B [j];
}
}
Multiplicam} / / fim
public static final void adicionar (double X [], duplo Y [], double Z [])
{
int n = x.length;
if (Y.length = n |! |! Z.length = n)
{
System.out.println ("Erro na Matrix.add," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <n, i + +) Z [i] = X [i] + Y [i];
} / / Fim adicionar
public static final vazio subtrair (double X [], duplo Y [], double Z [])
{
int n = x.length;
if (Y.length = n |! |! Z.length = n)
{
System.out.println ("Erro na Matrix.subtract," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <n, i + +) Z [i] = X [i] - Y [i];
Subtração} / / fim
public static final double Norm1 (double X [])
{
dobrar norma = 0,0;
int n = x.length;
for (int i = 0; i <n, i + +)
norma = norma + Math.abs (X [i]);
voltar norma;
} / / Fim Norm1
public static final double Norm2 (double X [])
{
dobrar norma = 0,0;
int n = x.length;
for (int i = 0; i <n, i + +)
norma = norma + X [i] * X [i];
voltar Math.sqrt (norma);
} / / Fim Norm2
estática normInf double public final (duplo X [])
{
dobrar norma = 0,0;
int n = x.length;
for (int i = 0; i <n, i + +)
norma = Math.max (norma, Math.abs (X [i]));
voltar norma;
NormInf} / / fim
public static unitvector vazio final (duplo X [], int j)
{
int n = x.length;
for (int i = 0; i <n, i + +) X [i] = 0,0;
X [j] = 1,0;
Unitvector} / / fim
public void static final zero (duplo X [])
{
int n = x.length;
for (int i = 0; i <n, i + +) X [i] = 0,0;
} / / Fim de zero
public static cópia vazio final (o dobro X [], duplo Y [])
{
int n = x.length;
if (Y.length! = n)
{
System.out.println ("Erro na Matrix.copy," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <n, i + +) Y [i] = X [i];
Cópia} / / fim
public static final boolean equals (final de double X [], double final, Y [])
{
int n = x.length;
boolean mesmo = true;
if (Y.length! = n)
{
System.out.println ("Erro na Matrix.equals," +
"Tamanhos incompatíveis.");
}
for (int i = 0; i <n, i + +)
mesmos = mesmos && (X [i] == Y [i]);
voltar mesmo;
} / / Fim é igual
public static final void print (double x [])
{
int n = x.length;
for (int i = 0; i <n, i + +)
System.out.println ("X [" + i + "] =" + X [i]);
} / / Fim de impressão
} / / Fim da classe Matrix
*/
/**
* @param args the command line arguments
*/
// TODO code application logic here
Ufa, começou a usar a tag “code” (embora esteja fazendo isso para todo o texto, não somente para o código-fonte).
Quanto ao tal segundo programa, você que tem 5 meses de Java não percebeu que ele ficou integralmente comentado (porque ficou todo em verde)?
(Se você for daltônico, o que não é nenhum demérito porque 8% dos homens têm algum problema relacionado a daltonismo, não vou ficar ressaltando essa diferença da cor verde)
Só para lhe dar uma pequena ajuda (não vou ajudar mais que isto), o texto que está originalmente como:
/**
*
* @author Juniorpúblic strictfp classe Matrix
deve ser corrigido para
/**
*
* @author Junior
*/
public strictfp classe Matrix
Não vou lhe explicar como é que você usa o recurso de busca do seu editor de texto para achar esse trecho de programa defeituoso.
[code]Obrigado Professor. se o Senhor poder me ajude estou sozinho. MUitíssimo obrigado
Cara achei um código na Internet parecido com o que você quer, mas não compilei pra testar:
import java.awt.*;
import java.util.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class matrixRain extends JFrame {
private static final int FONT_SIZE = 20;
private static final int NUMBER_OF_REPEATS = 5;
private static final String TEXT = new String("あ た
ア カ サ ザ ジ
ズ ゼ ゾ シ ス セ ソ キ ク ケ コ イ ウ エ オ ジャ な");
private static JPanel panel = new JPanel(null);
private static Random random = new Random();
private static JLabel label[] = new JLabel[NUMBER_OF_REPEATS];
public matrixRain() {
this.add(panel);
panel.setBackground(Color.BLACK);
}
public void scroll() {
//array to hold x coordinates for the labels
int[] random_x = new int[NUMBER_OF_REPEATS];
//create an infinite loop
while (true) {
//initialise all the labels to random characters
for (int i = 0; i < NUMBER_OF_REPEATS; i++) {
int character_initial = random.nextInt(TEXT.length());
random_x[i] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;
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 < (panel.getHeight() / FONT_SIZE) * 2; j++) {
int character = random.nextInt(TEXT.length());
//move each character
for (int i = 0; i < NUMBER_OF_REPEATS; i++) {
label[i].setBounds(random_x[i] * FONT_SIZE, j * (FONT_SIZE / 2), FONT_SIZE, FONT_SIZE);
label[i].setText("" + TEXT.charAt(character));
label[i].setForeground(new Color(0, 255 - (j * 5), 0));
for (int k = 0; k < NUMBER_OF_REPEATS; k++) {
int character_initial = random.nextInt(TEXT.length());
random_x[k] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;
label[k] = new JLabel("" + TEXT.charAt(character_initial));
panel.add(label[k]);
label[k].setFont(new Font("monospaced", Font.PLAIN, FONT_SIZE));
label[k].setForeground(new Color(0, 255, 0));
Color colour = label[k].getForeground();
if (colour.getGreen() <= 80) {
panel.remove(label[k]);
k = (panel.getHeight() / FONT_SIZE) * 2;
}
}
}
// pause between each character
try {
Thread.sleep(15);
} catch (Exception e) {
}
}
}
}
public static void main(String[] args) {
matrixRain frame = new matrixRain();
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();
}
}
Fonte: http://stackoverflow.com/questions/4710693/java-falling-matrix-code-like-the-movie-continued
O problema e que voce nao quer ajuda, quer o código pronto.
Já te explicaram mais de 10 vezes (e eu estava em umas 4 ou 5 delas) que o código está comentado. Ainda assim, seu código não evoluiu da primeira explicação até agora e continua comentado. Ou seja, você quer que alguém pegue seu código e faça EXATAMENTE o que você precisa.
Sinto muito, mas os fóruns não funcionam assim, exceto talvez em casos muito triviais.
Obrigado vou testar más e o outro código? e como eu coloco em um rodapé o efeito matrix em um jframe.
mesmo assim obrigado
Professor eu testei ele ele tá aberto, por favor se o Senhor poder feche ele pra mim e me devolva. segue o código abaixo
[code]/*
- matrixteste.java
- Created on 31 de Julho de 2013, 18:06
*/
package siscontabil;
/**import java.awt.;
import java.util.;
import javax.swing.*;
@SuppressWarnings(“serial”)
public class matrixRain extends JFrame {
private static final int FONT_SIZE = 20;
private static final int NUMBER_OF_REPEATS = 5;
private static final String TEXT = new String(“あ た
ア カ サ ザ ジ
ズ ゼ ゾ シ ス セ ソ キ ク ケ コ イ ウ エ オ ジャ な”);
private static JPanel panel = new JPanel(null);
private static Random random = new Random();
private static JLabel label[] = new JLabel[NUMBER_OF_REPEATS];
public matrixRain() {
this.add(panel);
panel.setBackground(Color.BLACK);
}
public void scroll() {
//array to hold x coordinates for the labels
int[] random_x = new int[NUMBER_OF_REPEATS];
//create an infinite loop
while (true) {
//initialise all the labels to random characters
for (int i = 0; i < NUMBER_OF_REPEATS; i++) {
int character_initial = random.nextInt(TEXT.length());
random_x[i] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;
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 < (panel.getHeight() / FONT_SIZE) * 2; j++) {
int character = random.nextInt(TEXT.length());
//move each character
for (int i = 0; i < NUMBER_OF_REPEATS; i++) {
label[i].setBounds(random_x[i] * FONT_SIZE, j * (FONT_SIZE / 2), FONT_SIZE, FONT_SIZE);
label[i].setText("" + TEXT.charAt(character));
label[i].setForeground(new Color(0, 255 - (j * 5), 0));
for (int k = 0; k < NUMBER_OF_REPEATS; k++) {
int character_initial = random.nextInt(TEXT.length());
random_x[k] = random.nextInt(panel.getWidth() / FONT_SIZE) - 1;
label[k] = new JLabel("" + TEXT.charAt(character_initial));
panel.add(label[k]);
label[k].setFont(new Font(“monospaced”, Font.PLAIN, FONT_SIZE));
label[k].setForeground(new Color(0, 255, 0));
Color colour = label[k].getForeground();
if (colour.getGreen() <= 80) {
panel.remove(label[k]);
k = (panel.getHeight() / FONT_SIZE) * 2;
}
}
}
// pause between each character
try {
Thread.sleep(15);
} catch (Exception e) {
}
}
}
}
public static void main(String[] args) {
matrixRain frame = new matrixRain();
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();
}
}
-
@author Junior
*/
public class matrixteste extends javax.swing.JFrame {/** Creates new form matrixteste */
public matrixteste() {
initComponents();
}/** This method is called from within the constructor to
-
initialize the form.
-
WARNING: Do NOT modify this code. The content of this method is
-
always regenerated by the Form Editor.
*/
@SuppressWarnings(“unchecked”)
//
private void initComponents() {setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);pack();
}//
/**
-
@param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new matrixteste().setVisible(true);
}
});
}
// Variables declaration - do not modify
// End of variables declaration -
}
[/code]