public void assignRedButton(YAnButton button) { // we store a pointer to the current instance of ColorMixer into // the userData Field button.set_userData(this); // and we register our static method to change red color as callback button.registerValueCallback(redCallback); }