Synthax to add the Action/ActionPerformed capability

I use the AbstractVisionComponent
I’m looking for the synthax to add the Action/ActionPerformed capability on my component ?

All you have to do is override the initEventSets function on your component’s bean info class to include an actionPerformed event:@Override protected void initEventSets() throws IntrospectionException { super.initEventSets(); addEventSet(YourComponentClass.class, "action", ActionListener.class, "actionPerformed"); }Then make your component class either extends a swing component that has action listeners or make it yourself. It is easier if you extend a class that has them already.

If you make it yourself you have to add the following variable to your class:protected EventListenerList listenerList = new EventListenerList();Then you have to add three functions to your class:[code]public void addActionListener(ActionListener l) {
listenerList.add(ActionListener.class, l);
}

public void removeActionListener(ActionListener l) {
listenerList.remove(ActionListener.class, l);
}

public ActionListener[] getActionListeners() {
return (ActionListener[])(listenerList.getListeners(
ActionListener.class));
}[/code]Lastly, you will need to let the listeners know the event happened somewhere:protected void fireActionPerformed() { Object[] listeners = listenerList.getListenerList(); ActionEvent e = null; for (int i = listeners.length-2; i>=0; i-=2) { if (listeners[i]==ActionListener.class) { if (e == null) { e = new ActionEvent(YourComponentClass.this, ActionEvent.ACTION_PERFORMED, "SomeAction"); } ((ActionListener)listeners[i+1]).actionPerformed(e); } } }That is it!

:thumb_left:

just another question,

how to filter the event “SomeAction” in python script called on “actionPerformed”
I fire actionPerformed for 2 differents events : “action1”, “action2”