LOS VIDEOS ESTAN EN http://www.youtube.com/user/rvnrodrigo
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class SUMA extends JApplet implements ActionListener
{
JTextField t1,t2,t3;
JLabel l1,l2,l3;
JButton b1;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
l1=new JLabel("DAME EL PRIMER VALOR: ");
t1=new JTextField(20);
l2=new JLabel("DAME EL SEGUNDO VALOR: ");
t2=new JTextField(20);
l3=new JLabel("EL RESULTADO ES: ");
t3=new JTextField(20);
b1=new JButton("SUMAR");
c.add(t1);
c.add(t2);
c.add(t3);
c.add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
double a,b,r;
a=Double.parseDouble(t1.getText());
b=Double.parseDouble(t2.getText());
r=a+b;
t3.setText(String.valueOf(r));
}
}
}
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario