martes, 12 de enero de 2010

Calculadora

codigo para operaciones de calculadora



public class Operaciones {


static double resultado;
public Operaciones(){
resultado = 0;
}

public static double seno(double x){
resultado = Math.sin(x);
return resultado;
}

public static double coseno(double x){
resultado = Math.cos(x);
return resultado;
}

public static double tangente(double x){
resultado = Math.tan(x);
return resultado;
}

public static double logaritmo(double x){
resultado = Math.log(x);
return resultado;
}

public static double raiz(double x){
if(x>=0){
resultado = Math.sqrt(x);
}else{
System.out.println("Solo valores postivos");
resultado = 0;
}
return resultado;

}

public static double suma(double x, double y){

resultado = x+y;

return resultado;
}

public static double resta(double x, double y){

resultado = x-y;

return resultado;
}
public static double multiplicacion(double x, double y){

resultado = x*y;

return resultado;
}

public static double division(double x, double y){

resultado = x/y;

return resultado;
}

public static void main(String args[]){
double y;
//Operaciones p = new Operaciones();
y = seno(3.141516);
System.out.println("El seno "+y);
}

}

Botones

/** Initializes the applet MisOperaciones */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

/** This method is called from within the init() method 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() {

jPanel1 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
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();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton15 = new javax.swing.JButton();
jButton16 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jButton17 = new javax.swing.JButton();
jButton18 = new javax.swing.JButton();
jButton19 = new javax.swing.JButton();
jButton20 = new javax.swing.JButton();
jTextField2 = new javax.swing.JTextField();

jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});

jLabel1.setText("Variable");

jButton1.setText("seno");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("coseno");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setText("tangente");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setText("Raiz");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setText("1");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setText("2");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton7.setText("3");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

jButton8.setText("4");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton9.setText("5");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

jButton10.setText("6");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});

jButton11.setText("7");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});

jButton12.setText("8");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});

jButton13.setText("9");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});

jButton14.setText("+");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});

jButton15.setText("0");
jButton15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton15ActionPerformed(evt);
}
});

jButton16.setText(".");
jButton16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton16ActionPerformed(evt);
}
});

jLabel2.setText("Resultados");

jButton17.setText("logaritmo");
jButton17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton17ActionPerformed(evt);
}
});

jButton18.setText("-");
jButton18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton18ActionPerformed(evt);
}
});

jButton19.setText("*");
jButton19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton19ActionPerformed(evt);
}
});

jButton20.setText("/");
jButton20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton20ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton10)
.addGap(18, 18, 18)
.addComponent(jButton18))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton14)
.addComponent(jButton11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton13)
.addGap(18, 18, 18)
.addComponent(jButton19))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton16)
.addGap(18, 18, 18)
.addComponent(jButton20))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton7)
.addGap(18, 18, 18)
.addComponent(jButton17))
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(127, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addGap(273, 273, 273))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton5)
.addComponent(jButton6)
.addComponent(jButton7)
.addComponent(jButton17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton8)
.addComponent(jButton9)
.addComponent(jButton10)
.addComponent(jButton18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(jButton11)
.addComponent(jButton12)
.addComponent(jButton13)
.addComponent(jButton19))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton4)
.addComponent(jButton14)
.addComponent(jButton15)
.addComponent(jButton16)
.addComponent(jButton20))
.addGap(18, 18, 18)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(51, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
}//
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here
aux += 1;
jTextField1.setText(aux);
}

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 2;
jTextField1.setText(aux);
}

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 3;
jTextField1.setText(aux);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
aux += 4;
jTextField1.setText(aux); // TODO add your handling code here:
}

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
aux += 5;
jTextField1.setText(aux); // TODO add your handling code here:
}

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 6;
jTextField1.setText(aux);
}

private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 7;
jTextField1.setText(aux);
}

private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 8;
jTextField1.setText(aux);
}

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 9;
jTextField1.setText(aux);
}

private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += 0;
jTextField1.setText(aux);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.coseno(r);
jTextArea1.setText("El coseno es :\n "+r);
aux = "";
jTextField1.setText(aux);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.tangente(r);
jTextArea1.setText("La tangente es :\n "+r);
aux = "";
jTextField1.setText(aux);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.raiz(r);
jTextArea1.setText("La raiz es :\n "+r);
aux = "";
jTextField1.setText(aux);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.logaritmo(r);
jTextArea1.setText("El logaritmo es :\n "+r);
aux = "";
jTextField1.setText(aux);
}
private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
x = Double.parseDouble(aux1);
aux2 = "+";
aux="";
jTextField1.setText("");
}
private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
x = Double.parseDouble(aux1);
aux2 = "-";
aux="";
jTextField1.setText("");
}
private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
x = Double.parseDouble(aux1);
aux2 = "^";
aux="";
jTextField1.setText("");
}
private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
x = Double.parseDouble(aux1);
aux2 = "*";
aux="";
jTextField1.setText("");
}
private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {
String aux1 = jTextField1.getText();
x = Double.parseDouble(aux1);
aux2 = "/";
aux="";
jTextField1.setText("");
}
private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {
if(aux2 == "+"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
jTextArea1.setText("La suma es: \n" +Operaciones.suma(x, r));
}
if(aux2 == "-"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
jTextArea1.setText("La resta es:\n" +Operaciones.resta(x,r));
}

if(aux2 == "^"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
jTextArea1.setText("La potencia es:\n" +Operaciones.exponente(x, r));
}
if(aux2 == "*"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
jTextArea1.setText("La multiplicacion es:\n" +Operaciones.multiplicacion(x, r));
}
if(aux2 == "/"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
jTextArea1.setText("La division es:\n" +Operaciones.division(x,r));
}
}
private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {
aux="";
jTextField1.setText("");
}

operaciones de matrices

public class botonesmatriz extends javax.swing.JApplet {

/** Initializes the applet botonesmatriz */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

/** This method is called from within the init() method 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() {

jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();

jLabel1.setText("operaciones: suma,resta y multiplicacion");

jButton1.setText("SUMA");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("RESTA");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setText("MULTIPLICACION");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jLabel2.setText("INGRESO MATRIZ 1");

jLabel3.setText("RESULTADO");

jButton4.setText("INVERSA");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setText("TRANSPUESTA");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setText("DETERMINANTE");

jLabel4.setText("INGRESO MATRIZ 2");

jLabel5.setText("FILAS");

jLabel6.setText("COLUMNAS");

jLabel7.setText("FILAS");

jLabel8.setText("COLUMNAS");

jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(357, 357, 357))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(41, 41, 41)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField2)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)))
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 168, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jTextField4))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(75, 75, 75)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(137, 137, 137))
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(188, 188, 188)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(105, 105, 105))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(51, 51, 51)
.addComponent(jLabel2))
.addComponent(jLabel4))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)))
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.addGap(14, 14, 14))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(21, 21, 21)
.addComponent(jButton2)
.addGap(18, 18, 18)
.addComponent(jButton3)))))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4)
.addGap(29, 29, 29)
.addComponent(jButton5)
.addGap(18, 18, 18)
.addComponent(jButton6))
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(277, 277, 277))
);
}//


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux = jTextField1.getText();
String aux1="";
int nF = Integer.parseInt(aux);
aux = jTextField2.getText();
int nC = Integer.parseInt(aux);
m = new Matriz(nF,nC);
m.leer();
aux1 += m1.toString();
aux = jTextField3.getText();
nF = Integer.parseInt(aux);
aux = jTextField4.getText();
nC = Integer.parseInt(aux);
m1 = new Matriz(nF,nC);
m1.leer();
aux1 += m1.toString();
jTextField7.setText("Multiplicacion de Matrices: \n"+aux1+(m.Multiplicacion(m1)).toString());

}

private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux = jTextField1.getText();
String aux1="";
int nF = Integer.parseInt(aux);
aux = jTextField2.getText();
int nC = Integer.parseInt(aux);
m = new Matriz(nF,nC);
m.leer();
aux1 += m1.toString();
aux = jTextField3.getText();
nF = Integer.parseInt(aux);
aux = jTextField4.getText();
nC = Integer.parseInt(aux);
m1 = new Matriz(nF,nC);
m1.leer();
aux1 += m1.toString();
jTextField7.setText("Suma de Matrices: \n"+aux1+(m.suma(m1)).toString());


}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux = jTextField1.getText();
String aux1="";
int nF = Integer.parseInt(aux);
aux = jTextField2.getText();
int nC = Integer.parseInt(aux);
m = new Matriz(nF,nC);
m.leer();
aux1 += m.toString();
aux = jTextField3.getText();
nF = Integer.parseInt(aux);
aux = jTextField4.getText();
nC = Integer.parseInt(aux);
m1 = new Matriz(nF,nC);
m1.leer();
aux1 += m1.toString();
jTextField7.setText("Resta de Matrices: \n"+aux1+(m.resta(m1)).toString());

}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux = jTextField5.getText();
int nF = Integer.parseInt(aux);
aux = jTextField6.getText();
int nC = Integer.parseInt(aux);
m= new Matriz(nF,nC);
m.leer();
jTextField7.setText("\nMATRIZ: \n"+(m.toString())+"INVERSA DE MATRICES: \n"+(m.Inversa().toString()));
jTextField7.setText("\nMATRIZ: \n"+(m1.toString())+"INVERSA DE MATRICES: \n"+(m1.Inversa().toString()));

}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux = jTextField5.getText();
String aux1="";
int nF = Integer.parseInt(aux);
aux = jTextField6.getText();
int nC = Integer.parseInt(aux);
m = new Matriz(nF,nC);
m.leer();
aux1+= m.toString();

jTextField7.setText("Transpuesta de Matrices: \n"+aux1+(m.Transpuesta()).toString());

}
public Matriz m;
public Matriz m1;

// Variables declaration - do not modify
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.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
// End of variables declaration

}

velocimetro lineal y pastel de porcentaje

import javax.swing.*;
import java.awt.*;

public class Velocimetro extends JFrame{
public Velocimetro(){
super("VELOCIMETRO");
setSize(400,400);
show();
}


public void paint(Graphics g){


super.paint(g);
g.setColor(Color.black);
g.drawOval(100, 150, 150, 150);
g.setColor(Color.blue);
g.drawString("0 [Km/h]", 100, 300);
g.setColor(Color.red);
g.drawString("280 [km/h]", 210, 300);
g.setColor(Color.black);
g.drawOval(170, 100, 20, 20);
g.setColor(Color.BLACK);

g.setColor(Color.lightGray);
g.fillOval(100, 150, 150, 150);




Sensor s = new Sensor();
s.leerVel();


if (s.getVel()>0 & s.getVel()<80){
g.setColor(Color.green);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.BLACK);
g.drawString(s.getVel()+" Km/h", 150, 220);
g.setColor(Color.GREEN);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.green);
g.drawString("Vas bien a ="+s.getVel()+"[km/h]", 170, 90);
g.fillRect(20, 380-s.getVel(), 20, s.getVel());
g.setColor(Color.black);
g.drawString(s.getVel()+" Km/h", 45, 380-s.getVel());


}
if(s.getVel()>=80 & s.getVel()<150){
g.setColor(Color.YELLOW);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.BLACK);
g.drawString(s.getVel()+" Km/h",150, 220);
g.setColor(Color.yellow);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.yellow);
g.drawString("¡¡¡Cuidado vas a= "+s.getVel()+"[km/h]!!!!!", 170, 90);
g.fillRect(20, 380-s.getVel(), 20, s.getVel());
g.setColor(Color.black);
g.drawString(s.getVel()+" Km/h", 45, 380-s.getVel());
}
if(s.getVel()>=150 & s.getVel()<=280){
g.setColor(Color.RED);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.BLACK);
g.drawString(s.getVel()+" Km/h", 150,220);
g.setColor(Color.RED);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.red);
g.drawString("!!!PELIGRO vas a= "+s.getVel()+"[km/h]!!!!", 170, 90);
g.fillRect(20, 380-s.getVel(), 20, s.getVel());
g.setColor(Color.black);
g.drawString(s.getVel()+" Km/h", 45, 380-s.getVel());
}






}




public static void main(String args[]){
Velocimetro vel = new Velocimetro();


vel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

Applet y su funcionamiento

Las applet Java son programas incrustados en otras aplicaciones, normalmente una página Web que se muestra en un navegador.
// Hola.java
import java.applet.Applet;
import java.awt.Graphics;

public class Hola extends Applet {
public void paint(Graphics gc) {
gc.drawString("Hola, mundo!", 65, 95);
}
}










La sentencia import indica al compilador de Java que incluya las clases java.applet. Applet y java.awt. Graphics, para poder referenciarlas por sus nombres, sin tener que anteponer la ruta completa cada vez que se quieran usar en el código fuente.
La clase Hola extiende (extends) a la clase Applet, es decir, es una subclase de ésta. La clase Applet permite a la aplicación mostrar y controlar el estado del applet. La clase Applet es un componente del AWT (Abstract Window Toolkit), que permite al applet mostrar una inteterfaz gráfica de usuario o GUI (Graphical User Interface), y responder a eventos generados por el usuario.
La clase Hola sobrecarga el método paint (Graphics) heredado de la superclase contenedora (Applet en este caso), para acceder al código encargado de dibujar. El método paint() recibe un objeto Graphics que contiene el contexto gráfico para dibujar el applet. El método paint() llama al método drawString (String, int, int) del objeto Graphics para mostrar la cadena de caracteres Hola, mundo! en la posición (65, 96) del espacio de dibujo asignado al applet.
La referencia al applet es colocada en un documento HTML usando la etiqueta
. Esta etiqueta o tag tiene tres atributos: code="Hola" indica el nombre del applet, y width="200" height="200" establece la anchura y altura, respectivamente, del applet. Un applet también pueden alojarse dentro de un documento HTML usando los elementos object, o embed, aunque el soporte que ofrecen los navegadores Web no es uniforme


bibliotecas AWT y SWING

UNIVERSIDAD TECNOLOGICA EQUINOCCIAL
PROGRAMACION II
Diego Ivan Moreno
BIBLOTECAS AWT Y SWING
¿Qué es la biblioteca SWING?
Swing es una biblioteca gráfica para Java. Incluye widgets para interfaz gráfica de usuario tales como cajas de texto, botones, desplegables y tablas.
Los componentes Swing
Incluye todo desde botones hasta splitpanes o tablas.
Soporte de Aspecto y Comportamiento Conectable
Le ofrece a cualquier componente Swing una amplia selección de aspectos y comportamientos. Por ejemplo, el mismo programa puede usar el Aspecto y Comportamiento Java o el Aspecto y Comportamiento Windows. Esperamos mucho más de los paquetes de Aspecto y Comportamiento -- incluyendo algo que use sonido en lugar de un 'look' visual.
API de Accesibilidad
Permite tecnologías asistidas como lectores de pantalla y display Braille para obtener información desde el interface de usuario.
Java 2D API (sólo JDK 1.2 )
Permite a los desarrolladores incorporar fácilmente gráficos 2D de alta calidad, texto, e imágenes en aplicaciones y applets Java.
Soporte de Drag and Drop (sólo JDK 1.2)
Proporciona la habilidad de arrastrar y soltar entre aplicaciones Java y aplicaciones nativas.
Las tres primeras características del JFC fueron implementadas sin ningún código nativo, tratando sólo con el API definido en el JDK 1.1. Como resultado, se convirtieron en una extensión del JDK 1.1. Esta versión fue liberada como JFC 1.1, que algunas veces es llamada 'Versión Swing'. El API del JFC 1.1 es conocido como el API Swing.
"Swing" era el nombre clave del proyecto que desarrolló los nuevos componentes. Aunque no es un nombre oficial, frecuentemente se usa para referirse a los nuevos componentes y al API relacionado. Está inmortalizado en los nombres de paquete del API Swing, que empiezan con "javax.swing."
¿Qué es AWT?
Los componentes AWT son aquellos proporcionados por las plataformas JDK 1.0 y 1.1. Aunque JDK 1.2 todavía soporta componentes AWT, recomendamos encarecidamente el uso de componente Swing en su lugar. Puedes identificar los componentes Swing porque sus nombres empiezan con J. Por ejemplo, la clase button del AWT se llama Button, y la clase button de Swing se llama JButton. Los componentes AWT están en el paquete java.awt, mientras que los componentes Swing están en el paquete javax.swing.
La mayor diferencia entre los componentes AWT y los componentes Swing es que éstos últimos están implementados sin nada de código nativo. Los Swing pueden tener más funcionalidad que los componentes AWT, porque no están restringidos al denominador común, las características presentes en cada plataforma. El no tener código nativo también permite que los componentes Swing sean vendidos como añadidos al JDK 1.1, en lugar de sólo formar parte del JDK 1.2.
Incluso el más sencillo de los componentes Swing tiene capacidades que van más allá de lo que ofrecen los componentes AWT.
• Los botones y las etiquetas Swing pueden mostrar imágenes además del texto.
• Se pueden añadir o modificar fácilmente los bordes dibujados alrededor de casi cualquier componente Swing. Por ejemplo, es fácil poner una caja alrededor de un contenedor o una etiqueta.
• Se puede modificar fácilmente el comportamiento o la apariencia de un componente Swing llamando a métodos o creando una subclase.
• Los componentes Swing no tienen porque ser rectangulares. Por ejemplo, los botones pueden ser redondos.
• Las tecnologías asistidas como los lectores de pantallas pueden fácilmente obtener información desde los componentes Swing. Por ejemplo, una herramienta puede fácilmente obtener el texto mostrado en un botón o en una etiqueta.
Otra característica Swing es que se puede especificar el Aspecto y Comportamiento que utilice el GUI de nuestro programa. Por el contrario, los componentes AWT siempre tienen el aspecto y comportamiento de la plataforma nativa.
Otra característica interesante es que los componentes Swing con estado usan modelos para mantener el estado. Por ejemplo, un JSlider usa un objeto BoundedRangeModel para contener su valor actual y un rango de valores legales. Los modelos se configuran automáticamente, por eso no tenemos que tratar con ellos, a menos que queramos tomar ventaja de la potencia que pueden ofrecernos.

lunes, 11 de enero de 2010

velocimetro

import javax.swing.*;

public class sensordatos {private int vel;


public sensordatos(){


}


public void setVel(int v) {
vel = v;
}


public int getVel(){
return vel;
}


public void leerVel(){
String aux;
aux = JOptionPane.showInputDialog("velocidad en [Km/h]");
vel = Integer.parseInt(aux);
}


public static void main(String args[]){
sensordatos s = new sensordatos();
s.leerVel();
System.out.println("VELOCIDAD = "+s.getVel());
}

import javax.swing.*;
import java.awt.*;



public class Interfase2 extends JFrame{
public Interfase2(){
super("VELOCIMETRO");
setSize(400,400);
show();
}


public void paint(Graphics g){


super.paint(g);
g.setColor(Color.black);
g.drawOval(100, 150, 150, 150);
g.setColor(Color.blue);
g.drawString("0 [Km/h]", 100, 300);
g.setColor(Color.red);
g.drawString("240 [km/h]", 210, 300);
g.setColor(Color.black);
g.drawOval(170, 100, 20, 20);


g.setColor(Color.white);
g.fillOval(100, 150, 150, 150);




sensordatos s = new sensordatos();
s.leerVel();


if (s.getVel()>0 & s.getVel()<80){
g.setColor(Color.green);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.LIGHT_GRAY);
g.drawString(s.getVel()+" Km/h", 150, 220);
g.setColor(Color.GREEN);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.green);
g.drawString("Vas bien a ="+s.getVel()+"[km/h]", 170, 90);
}
if(s.getVel()>=80 & s.getVel()<150){
g.setColor(Color.YELLOW);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.lightGray);
g.drawString(s.getVel()+" Km/h",150, 220);
g.setColor(Color.GREEN);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.yellow);
g.drawString("¡¡¡Cuidado vas a= "+s.getVel()+"[km/h]!!!!!", 170, 90);
}
if(s.getVel()>=150 & s.getVel()<=240){
g.setColor(Color.RED);
g.fillArc(100, 150,150,150,225,-(320-(315-s.getVel())));
g.setColor(Color.lightGray);
g.drawString(s.getVel()+" Km/h", 150,220);
g.setColor(Color.RED);
g.fillOval(170, 100, 20, 20);
g.setColor(Color.red);
g.drawString("!!!PELIGRO vas a= "+s.getVel()+"[km/h]!!!!", 170, 90);
}




}




public static void main(String args[]){
Interfase2 vel = new Interfase2();


vel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

lunes, 7 de diciembre de 2009

operaciones con matrices

public class TodasOperaciones extends javax.swing.JApplet {

/** Initializes the applet TodasOperaciones */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
@SuppressWarnings("unchecked")
//
private void initComponents() {

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea3 = new javax.swing.JTextArea();
Multiplicacion = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();

jPanel1.setBackground(new java.awt.Color(204, 255, 255));

jLabel1.setForeground(new java.awt.Color(255, 51, 51));
jLabel1.setText("Operaciones Matrices");

jLabel2.setText("Ingrese las Matrices");

jLabel3.setText("Matriz 1");

jLabel4.setText("Numero de Filas");

jLabel5.setText("Numero de Columnas");

jLabel6.setText("Matriz 2");

jLabel7.setText("Numero de Filas");

jLabel8.setText("Numero de Columnas");

jButton1.setText("Leer Matriz 1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Imprimir Matriz 1");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);

jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);

jButton3.setBackground(new java.awt.Color(255, 204, 255));
jButton3.setText("Leer Matriz 2");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setText("Suma");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setBackground(new java.awt.Color(255, 204, 255));
jButton5.setText("Imprimir Matriz 2");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setText("Resta");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jTextArea3.setColumns(20);
jTextArea3.setRows(5);
jScrollPane3.setViewportView(jTextArea3);

Multiplicacion.setText("Multiplicacion");
Multiplicacion.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MultiplicacionActionPerformed(evt);
}
});

jButton8.setText("M. Transpuesta");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(305, 305, 305)
.addComponent(jLabel1))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(98, 98, 98)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(39, 39, 39)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField2)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(191, 191, 191)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton6)
.addComponent(jButton4))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton8)
.addComponent(Multiplicacion))
.addGap(86, 86, 86)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField4, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)))
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(35, 35, 35)
.addComponent(jButton5)))))
.addContainerGap(2029, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(26, 26, 26)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(16, 16, 16)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(13, 13, 13)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(jButton5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(36, 36, 36)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton4)
.addComponent(Multiplicacion))
.addGap(30, 30, 30)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton8)
.addComponent(jButton6)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(125, 125, 125))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
.addContainerGap())
);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String aux = jTextField1.getText();
nF = Integer.parseInt(aux);
aux = jTextField2.getText();
nC = Integer.parseInt(aux);
m = new Matriz(nF,nC);
m.leer();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea2.setText(m.toString());
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String aux = jTextField3.getText();
nF = Integer.parseInt(aux);
aux = jTextField4.getText();
nC = Integer.parseInt(aux);
s = new Matriz(nF,nC);
s.leer();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
E = new Matriz(nF,nC);
E = m.suma(s);
jTextArea1.setText(E.toString());
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea3.setText(s.toString());
}
private void MultiplicacionActionPerformed(java.awt.event.ActionEvent evt) {
B = new Matriz(nF,nC);
B = m.Multiplicacion(s);
jTextArea1.setText(B.toString());
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {

}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

A = new Matriz(nF,nC);
A = m.resta(s);
jTextArea1.setText(A.toString());
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

String aux = jTextField5.getText();
int nF = Integer.parseInt(aux);
aux = jTextField6.getText();
int nC = Integer.parseInt(aux);
m3= new Matriz(nF,nC);
m3.leerMatriz();
jTextArea2.setText("\nMATRIZ: \n"+(m3.toString())+"INVERSA DE MATRICES: \n"+(m3.Inversa().toString()));
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

String aux = jTextField5.getText();
int nF = Integer.parseInt(aux);
aux = jTextField6.getText();
int nC = Integer.parseInt(aux);
m3= new Matriz(nF,nC);
m3.leerMatriz();

jTextArea2.setText("\nMATRIZ: \n"+(m3.toString())+"TRANSPUESTA DE MATRIZ: \n"+(m3.Transpuesta().toString()));
}


public int nF;
public int nC;
public int m3;
public Matriz m;
public Matriz s;
public Matriz E;
public Matriz A;
public Matriz B;

// Variables declaration - do not modify
private javax.swing.JButton Multiplicacion;
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 jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextArea jTextArea3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
// End of variables declaration
}