thanks
dan
debug(7);
global('$frame $button $clicked');
import javax.swing.*;
import java.awt.*;
$frame = [new JFrame: "Test"];
[$frame setSize: 240, 120];
[$frame setDefaultCloseOperation: [JFrame EXIT_ON_CLOSE]];
$button = [new JButton: "Click me"];
[[$frame getContentPane] add: $button];
[$frame show];
$clicked = 0;
sub button_pressed {
# $0 is "actionPerformed"
# $1 is a java.awt.event.ActionEvent object
$clicked++;
[[$1 getSource] setText: "Clicked $clicked time(s)"];
}
# add &button_pressed as our action listener
[$button addActionListener: &button_pressed];
Sleep converts closures into proxy instances of Java objects when
needed. A Java method call on a closure passes $0 as the method name
and each arg as $1 .. $n. This only works with interfaces.
If you want to perform this conversion yourself (rather than relying
on Sleep to figure it out) use the newInstance function.
http://sleep.dashnine.org/manual/newInstance.html
-- Raphael