He creado una ventana en donde tengo 3 matrices creadas en textField, en donde las dos primeras son para una operación de resta, y la tercera para guardar el resultado, ahora, se que para operaciones con matrices se utiliza el ciclo "for", mi duda esta en como hago las operaciones de las matrices de TextField ¿tengo que declarar las matices con el metodo interger? con get text y set text? o como?
dejo el codigo:
package matrizop;
import java.awt.*;
import java.awt.event.*;
public class matrizop extends Frame implements WindowListener, ActionListener {
TextField m[][], t[][], z[][];
Button b;
Label l;
public matrizop(){
setLayout(null);
setTitle("Matriz");
setBounds(100,80,520,280);
addWindowListener(this);
m=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
m[j]=new TextField("");
m[j].setBounds(40*(j+1),40*(i+2),35,35);
add(m[j]);
}
}
t=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
t[j]=new TextField("");
t[j].setBounds(40*(j+5),40*(i+2),35,35);
add(t[j]);
}
}
z=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
z[j]=new TextField("");
z[j].setBounds(40*(j+9),40*(i+2),35,35);
add(z[j]);
}
}
b=new Button("-");
b.setBounds(170,130,20,20);
b.addActionListener(this);
add(b);
l=new Label("=");
l.setBounds(330,130,20,20);
add(l);
}
public static void main(String[] args) {
matrizop p =new matrizop();
p.setVisible(true);
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void actionPerformed(ActionEvent e) {
}
}
--------
de antemano gracias.
dejo el codigo:
package matrizop;
import java.awt.*;
import java.awt.event.*;
public class matrizop extends Frame implements WindowListener, ActionListener {
TextField m[][], t[][], z[][];
Button b;
Label l;
public matrizop(){
setLayout(null);
setTitle("Matriz");
setBounds(100,80,520,280);
addWindowListener(this);
m=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
m[j]=new TextField("");
m[j].setBounds(40*(j+1),40*(i+2),35,35);
add(m[j]);
}
}
t=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
t[j]=new TextField("");
t[j].setBounds(40*(j+5),40*(i+2),35,35);
add(t[j]);
}
}
z=new TextField[3][3];
for(int i=0;i<=2;i++){
for(int j=0;j<=2;j++){
z[j]=new TextField("");
z[j].setBounds(40*(j+9),40*(i+2),35,35);
add(z[j]);
}
}
b=new Button("-");
b.setBounds(170,130,20,20);
b.addActionListener(this);
add(b);
l=new Label("=");
l.setBounds(330,130,20,20);
add(l);
}
public static void main(String[] args) {
matrizop p =new matrizop();
p.setVisible(true);
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void actionPerformed(ActionEvent e) {
}
}
--------
de antemano gracias.