On 1/12/18 10:26 AM, jeffrey kutcher wrote:
             m = o.getClass().getMethod("add", new Class[] { Object.class, });
             o = m.invoke(o, new Object[] { button1, });

o.getClass().getMethod(...) is an anti-pattern for finding a public method.   Object.getClass() returns the implementation class while you want to invoke a public method `javafx.collections.ObservableList::add` in this case.  In this case, the declaring class of the method is known and so one way to fix it is to use the specific Class:

Class<?> observableListClass = javafx.collections.ObservableList.class;
m = observableListClass.getMethod("add",new Class[] { Object.class, });
o = m.invoke(o,new Object[] { button1, });

Mandy




Reply via email to