I apologize to the list for not directing prior posts
about this issue to the list.
--- Mike Cantone <[EMAIL PROTECTED]> wrote:
> This question is in reference to Java-Swing-0.02.
> The author, Philip
> Crow suggested addressing questions to this list
> which he monitors. OK,
> here goes:
>
> In general things are set up and work very nicely.
> Thanks!
> But I need to create a Timer object. I tried this:
>
> my $timer = Timer->new(1000,\&myTimerListener);
>
> with the following listener:
>
> sub myTimerListener {
> my $generating_object = shift;
> my $event = shift;
> print "Hello, Timer!\n";
> }
>
>
> When I try to run, I get this:
>
> Can't convert CODE(0x52b3b0) to object
> java.awt.event.ActionListener at
> /usr/lib/perl5/site_perl/5.8.5/Inline/Java/Object.pm
> line 101
>
> I understand the method whereby I might do something
> like this:
As I pointed out in private email, the Timer is
different from the other event sources. I didn't know
that when I wrote the module, since I had never (or at
least not recently) used Timers.
Timer requires a listener passed to its constructor.
This required a bit of redesign. Version 0.03 of
Java::Swing is now making its way around the mirrors.
With it you can use the Timer in a similar spirit to
the other event sources. Do it like this (as shown in
the updated pod):
my $timer = Timer->new(
$delay,
{ actionPerformed => \&myTimerListener}
);
Then, don't forget to start the timer before starting
the Java::Swing event loop:
$timer->start();
my $swinger = Java::Swing->new();
$swinger->start();
It should also be possible to connect additional
listening callbacks to the Timer by calling connect,
but I haven't tried that.
>...
> Thanks for listening,
>
> Mike
>
Thanks for writing. Most of the code provided with
this module is autogenerated. That means I haven't
considered special cases very much and most of them
don't work. I need people who do use them to point
out where they fail.
Phil
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com