@quark @GoToLoop thks for your lights !
Et voilà the result:
void setup() {
}
int count = 0;
void draw() {
count++;
select_callback("my_method",this,"truc", count);
}
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
void select_callback(String callbackMethod, Object callbackObject, String s, int i) {
try {
Class<?> callbackClass = callbackObject.getClass();
Method selectMethod =
callbackClass.getMethod(callbackMethod,
new Class[] { String.class, int.class });
selectMethod.invoke(callbackObject, s,i);
} catch (IllegalAccessException iae) {
System.err.println(callbackMethod + "() must be public");
} catch (InvocationTargetException ite) {
ite.printStackTrace();
} catch (NoSuchMethodException nsme) {
System.err.println(callbackMethod + "() could not be found");
}
}
void my_method(String stuff, int value) {
println(stuff,value);
}