martes, 19 de abril de 2011

Java: public class Boton extends Applet implements ActionListener

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

/*
<APPLET
    CODE=boton.class
    WIDTH=200
    HEIGHT=200 >
</APPLET>
*/

public class boton extends Applet implements ActionListener {

    TextField text1;
    Button button1;
    public void init()
    {
        text1 = new TextField(20);
        add(text1);
        button1 = new Button("¡Haga clic aqui!");
        add(button1);
        button1.addActionListener(this);
    }
    public void actionPerformed(ActionEvent event)
    {
        String msg = new String ("¡Hola desde Java!");
        if(event.getSource() == button1){
            text1.setText(msg);
        }
    }
}
Compartir:

0 comentarios:

Publicar un comentario