Example usage for java.beans EventHandler create

List of usage examples for java.beans EventHandler create

Introduction

In this page you can find the example usage for java.beans EventHandler create.

Prototype

public static <T> T create(Class<T> listenerInterface, Object target, String action, String eventPropertyName,
        String listenerMethodName) 

Source Link

Document

Creates an implementation of listenerInterface in which the method named listenerMethodName passes the value of the event expression, eventPropertyName , to the final method in the statement, action , which is applied to the target .

Usage

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ??????//from w ww  . j av a 2  s . c om
 * 
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see KeyListener#keyPressed(java.awt.event.KeyEvent)
 */
public EventQuery keydown(Object target, String action, String property) {
    KeyListener keyPressed = EventHandler.create(KeyListener.class, target, action, property, "keyPressed");
    for (Component child : list) {
        child.addKeyListener(keyPressed);
    }
    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ?????//from  w  w w.jav a  2s  .  c  om
 * 
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see KeyListener#keyReleased(java.awt.event.KeyEvent)
 */
public EventQuery keyup(Object target, String action, String property) {
    KeyListener keyReleased = EventHandler.create(KeyListener.class, target, action, property, "keyReleased");
    for (Component child : list) {
        child.addKeyListener(keyReleased);
    }
    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ?????/* w w w.  j  av  a  2s.c  o m*/
 * 
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see KeyListener#keyTyped(java.awt.event.KeyEvent)
 */
public EventQuery keypress(Object target, String action, String property) {
    KeyListener keyTyped = EventHandler.create(KeyListener.class, target, action, property, "keyTyped");
    for (Component child : list) {
        child.addKeyListener(keyTyped);
    }
    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ???????????????// w  w  w.  ja v  a  2  s.c o  m
 * ????????
 * 
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see TextListener#textValueChanged(java.awt.event.TextEvent)
 * @see ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
 * @see PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 * @see ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
 */
public EventQuery change(Object target, String action, String property) {
    TextListener textValueChanged = EventHandler.create(TextListener.class, target, action, property,
            "textValueChanged");
    ListSelectionListener valueChanged = EventHandler.create(ListSelectionListener.class, target, action,
            property, "valueChanged");
    PropertyChangeListener propertyChange = EventHandler.create(PropertyChangeListener.class, target, action,
            property, "propertyChange");
    ChangeListener stateChanged = EventHandler.create(ChangeListener.class, target, action, property,
            "stateChanged");
    for (Component child : list) {
        if (TextComponent.class.isInstance(child)) {
            TextComponent.class.cast(child).addTextListener(textValueChanged);
        } else if (JTable.class.isInstance(child)) {
            JTable.class.cast(child).getSelectionModel().addListSelectionListener(valueChanged);
        } else if (JTabbedPane.class.isInstance(child)) {
            JTabbedPane.class.cast(child).addChangeListener(stateChanged);
        } else {
            child.addPropertyChangeListener(propertyChange);
        }
    }

    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ???????//www  .ja v a2s. c o m
 * 
 * @param name ???????null ???????????
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public EventQuery change(String name, Object target, String action, String property) {
    PropertyChangeListener propertyChange = EventHandler.create(PropertyChangeListener.class, target, action,
            property, "propertyChange");
    for (Component child : list) {
        if (name != null) {
            child.addPropertyChangeListener(name, propertyChange);
        } else {
            child.addPropertyChangeListener(propertyChange);
        }
    }

    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ??????????//from  ww w .java  2s .  c  om
 * 
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see MouseListener#mousePressed(java.awt.event.MouseEvent)
 * @see MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
 */
public EventQuery swipe(Object target, String action, String property) {
    //      MouseListener mousePressed = EventHandler.create(MouseListener.class, target, action, property, "mousePressed");
    MouseMotionListener mouseDragged = EventHandler.create(MouseMotionListener.class, target, action, property,
            "mouseDragged");
    MouseSwipeHandler swipeHandler = new MouseSwipeHandler();
    for (Component child : list) {
        //         child.addMouseListener(mousePressed);
        child.addMouseMotionListener(mouseDragged);
        child.addMouseListener(swipeHandler);
        child.addMouseMotionListener(swipeHandler);
    }

    return this;
}