package boton2; import java.awt.*; import java.awt.event.*; import java.applet.*; public class BotonApplet2 extends Applet{ Label lMensaje = new Label(); Button btnAceptar = new Button(); FlowLayout flowLayout1 = new FlowLayout(); //Construct the applet public BotonApplet2() { } //Initialize the applet public void init() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { int ancho = Integer.parseInt(this.getParameter("WIDTH")); int alto = Integer.parseInt(this.getParameter("HEIGHT")); this.setSize(new Dimension(ancho, alto)); lMensaje.setText("Pulsar el botón "); btnAceptar.setLabel("Aceptar"); AccionBoton accion=new AccionBoton(lMensaje); btnAceptar.addActionListener(accion); flowLayout1.setHgap(25); this.setLayout(flowLayout1); this.add(lMensaje, null); this.add(btnAceptar, null); } } //********************************* class AccionBoton implements ActionListener{ private Label label; public AccionBoton(Label label){ this.label=label; } public void actionPerformed(ActionEvent ev){ label.setText("Se ha pulsado el botón"); } }