miércoles, 11 de enero de 2012

Añadir un evento a un botón Swing

Éste es el código para añadir un evento a un botón Swing en Java.
   private JButton boton = new JButton("Botón");

   boton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
         System.out.println("Click!");
      }
   }); 
 
Aquí tenéis la documentación: Enlace

No hay comentarios:

Publicar un comentario