package boton5; import java.awt.*; import java.awt.event.*; import java.applet.*; public class BotonApplet5 extends Applet{ Label lMensaje = new Label(); Button btnAceptar = new Button(); FlowLayout flowLayout1 = new FlowLayout(); //Construct the applet public BotonApplet5() { } //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"); btnAceptar.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ btnAceptar_actionPerformed(e); } }); flowLayout1.setHgap(25); this.setLayout(flowLayout1); this.add(lMensaje, null); this.add(btnAceptar, null); } void btnAceptar_actionPerformed(ActionEvent ev) { lMensaje.setText("Se ha pulsado el botón"); } }