Ejemplos Java

Páginas: 2 (315 palabras) Publicado: 18 de julio de 2012
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

//
public class AppletEventos1 extends Applet implements ActionListener {
Label l1, l2, l3;
TextField t1,t2,t3;Button b2,b3, b4, b5, b6, b7, b8;

public AppletEventos1() {
l1 = new Label("Numero1");
t1 = new TextField(8);
l2 = new Label("Numero2");
t2 = new TextField(8);l3 = new Label("Resul");
t3 = new TextField(8);
b2 = new Button("Multiplicacion");
b3 = new Button("Resta");
b4 = new Button("Division");
b5 = newButton("Raiz_de_1");
b6 = new Button("Raiz_de_2");
b7 = new Button("Mayor");
b8 = new Button("Limpia");
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);add(t3);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);

b2. addActionListener(this);
b3. addActionListener(this);b4. addActionListener(this);
b5. addActionListener(this);
b6. addActionListener(this);
b7. addActionListener(this);
b8. addActionListener(this);

}public void actionPerformed(ActionEvent ae) {
if (ae.getActionCommand() == "Suma") {
int n = Integer.parseInt(t1.getText());
int m = Integer.parseInt(t2.getText());int Suma = 0;
Suma=n+m;
t3.setText("" + Suma);
}
if (ae.getActionCommand() == "Multiplicacion") {
int n = Integer.parseInt(t1.getText());
int m =Integer.parseInt(t2.getText());
int Multiplicacion = 0;
Multiplicacion=n*m;
t3.setText("" + Multiplicacion);
}
if (ae.getActionCommand() == "Resta") {int n = Integer.parseInt(t1.getText());
int m = Integer.parseInt(t2.getText());
int Resta = 0;
Resta=n-m;
t3.setText("" + Resta);
}
if...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Ejemplos java
  • Ejemplo En Java
  • Ejemplo Java
  • Ejemplo de Herencia en Java
  • Ejemplo de clase en Java
  • Ejemplos De Java Script
  • Ejemplo POO en java
  • Java ejemplo 2

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS