LOS VIDEOS ESTAN EN http://www.youtube.com/user/rvnrodrigo
import javax.swing.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class sumar_jcheckbox extends JApplet implements ItemListener
{
JTextField t1,t2,t3;
JCheckBox suma;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
t1=new JTextField("VALOR UNO: ",30);
t2=new JTextField("VALOR DOS",30);
t3=new JTextField("RESULTADO",30);
suma=new JCheckBox("SUMAR");
c.add(t1);
c.add(t2);
c.add(t3);
c.add(suma);
suma.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
double a,b,r;
if(e.getItemSelectable()==suma)
{
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