[libinline-java-perl] 385/398: ok

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.55
in repository libinline-java-perl.

commit f05cd86076854017de8cdc0b893995db3796a2c7
Author: patrick_leb <>
Date:   Fri Oct 2 14:23:40 2009 +0000

    ok
---
 t/swing_callback.pl | 52 +++++++++++++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/t/swing_callback.pl b/t/swing_callback.pl
index 0fb8879..679b82b 100644
--- a/t/swing_callback.pl
+++ b/t/swing_callback.pl
@@ -1,31 +1,43 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
+use blib ;
 
-use Inline Java => "DATA";
+use Inline Java => "DATA" ;
 
-my $cnt = 0 ;
-my $greeter = MyButton->new();
-$greeter->StartCallbackLoop() ;
-print "loop done\n" ;
 
+package EventHandler ;
+
+sub new {
+	my $class = shift ;
+	my $max = shift ;
 
-###########################################
+	return bless({max => $max, nb => 0}, $class) ;
+}
 
 
 sub button_pressed {
-  $cnt++ ;
-  print "Button Pressed $cnt times (from perl)\n" ;
-  if ($cnt > 10){
-	 print "sleep starting\n" ;
-	 sleep(10) ;
-	 print "sleep stopping\n" ;
-	 # $greeter->StopCallbackLoop() ;
-  }
+	my $this = shift ;
+	my $button = shift ;
+
+	$this->{nb}++ ;
+	print "Button Pressed $this->{nb} times (from perl)\n" ;
+	if ($this->{nb} > $this->{max}){
+		$button->StopCallbackLoop() ;
+	}
  
-  return $cnt ;
+	return $this->{nb} ;
 }
 
+
+my $button = MyButton->new(new EventHandler(10));
+$button->StartCallbackLoop() ;
+print "loop done\n" ;
+
+
+
+package main ;
+
 __DATA__
 __Java__
 
@@ -37,10 +49,11 @@ import java.awt.event.*;
 public class MyButton extends    InlineJavaPerlCaller
                       implements ActionListener
 {
-  private String cnt = "0" ;
+  InlineJavaPerlObject po = null ;
 
-  public MyButton() throws InlineJavaException
+  public MyButton(InlineJavaPerlObject _po) throws InlineJavaException
   {
+    po = _po ;
     // create frame
     JFrame frame = new JFrame("MyButton");
     frame.setSize(200,200);
@@ -61,10 +74,7 @@ public class MyButton extends    InlineJavaPerlCaller
   {
     try
     {
-      if (cnt.equals("10")){
-        InterruptWaitForCallback() ;
-      }
-      cnt = (String)CallPerlSub("main::button_pressed", new Object [] {});
+      String cnt = (String)CallPerlMethod(po, "button_pressed", new Object [] {this});
       System.out.println("Button Pressed " + cnt + " times (from java)") ;
     }
     catch (InlineJavaPerlException pe)  { }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git



More information about the Pkg-perl-cvs-commits mailing list