Sena semana 1 actividad 1-1
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 b1,b2, b3, b4, b5, b6, b7, b8;
public AppletEventos1() {
l1 = new Label("Numero 1");
t1 = new TextField(8);
l2 = newLabel("Numero 2");
t2 = new TextField(8);
b1 = new Button("Suma");
b2 = new Button("Resta");
b3 = new Button("Multiplica");
b4 = new Button("Divide");
b5 = newButton("Raiz de 1");
b6 = new Button("Raiz de 2");
b7 = new Button("Mayor");
b8 = new Button("Limpia");
l3 = new Label("Resultado");
t3 = new TextField(8);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(l3);add(t3);
b1.addActionListener(this);
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.getSource() == b1) {
int a = Integer.parseInt(t1.getText());
int b = Integer.parseInt(t2.getText());
int suma = 0;
suma= a+b;
t3.setText("" + suma);
}
if(ae.getActionCommand() == "Resta") {
int a = Integer.parseInt(t1.getText());
int b = Integer.parseInt(t2.getText());
int resta = 0;
resta= a-b;
t3.setText("" +resta);
}
if (ae.getSource() == b3) {
int a = Integer.parseInt(t1.getText());
int b = Integer.parseInt(t2.getText());
int multi = 0;
multi= a*b;...
Regístrate para leer el documento completo.