add Action Listener to JButton via Java Bean EventHandler - Java Swing

Java examples for Swing:Action

Description

add Action Listener to JButton via Java Bean EventHandler

Demo Code


//package com.java2s;
import java.awt.event.ActionListener;
import java.beans.EventHandler;
import javax.swing.JButton;

public class Main {
    public static void addActionListener(JButton btn, Object target,
            String method) {/*  w w w.  j  av a  2  s  .  co m*/
        btn.addActionListener((ActionListener) EventHandler.create(
                ActionListener.class, target, method));
    }
}

Related Tutorials