Inner classes

Glen Starchman glen at enabledventures.com
Fri Jun 15 15:32:49 EDT 2001


Samuele Pedroni wrote:
> 
> I hope you know that you can do the following in jython:
> 
> class StupidExample:
> 
>  def butAAction(self,e):
>    ....
> 
>  def butBAction(sel,e):
>    ...
> 
>  def __init__(self):
>    self.butA = JButton("A",actionPerformed=self.butAAction);
>    self.butB = JButton("B",actionPerformed=self.butBAction);
> 
> or even lambdas instead of bounded methods if your code is short enough

Sure. But I specifically did not show that because I see using the
actionPerformed= to be:

1) a dirty, dirty hack
2) counter-intuitive since the JButton in Java does not have a
constructor that takes a method (obviously)
3) I *try* to keep my Jython code as Java-like (without filthy inner
classes) as possible, so if, god forbid, I need to recode in Java it
is an easier process.
 
> 
> <wink> Samuele Pedroni.

<wink>*2



More information about the Python-list mailing list