NUEVO EJEMPLO
import javax.swing.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DATOS_POR_APPLET extends Applet implements ActionListener
{
public TextField t1,t2,t3,t4;
public Button b1,b2,b3;
public void init()//inicia la interfaz
{
t1=new TextField(30);
t2=new TextField(30);
t3=new TextField(30);
t4=new TextField(35);
b1=new Button("NOMBRE");
b2=new Button("APELLIDO");
b3=new Button("TELEFONO");
add(t1);
add(t2);
add(t3);
add(t4);
add(b1);
add(b2);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
t4.setText(t1.getText());
}
if(e.getSource()==b2)
{
t4.setText(t2.getText());
}
if(e.getSource()==b3)
{
t4.setText(t3.getText());
}
}
}
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario