Keith B. wrote:
that uses Java Swing for the GUI framework. Swing makes heavy use of
So that’s an example of a JRuby app in which the
directly-modify-Java-class approach would not work (I don’t think),
whereas the subclass-Java-class approach would. Pretty cool what you did
Thanks very much for these answers.
I spent more time looking into this, adding yet more proof that the
surest way to solve a problem is to post a question about it because
inevitable (well, maybe) one then figures it out.
Turns out that i was not able to get my code to work at first because I
was not correctly addressing the class of interest. Instead I was
creating a new class; the intended target of this code was unaware.
Once I was able to refer to the correct class I did this:
alias_method :leap_hands, :hands
hands = leap_hands
# My own nefarious code here
In actual use a Frame object (created by third-party Java code) is
passed to a callback method (onFrame) that has to be defined in a
Listener class that handles the callback. In my JRuby app that class
is sub-classed from a Java class. The objects (and sub-objects) it gets
passed though can be already modified with whatever enhancements I see
fit. Which, of course, is very cool.