Menu

Getting access to Java Object

2004-05-13
2004-05-20
  • Pierre Morel

    Pierre Morel - 2004-05-13

    I have a product www.ultrid.com that supported 10 BSF languages. I would like to know how I can get access to Java objects (Swing components) from whithin the BSFPerl script. I am not familiar with Perl, so maybe it is impossible to that. If you can show me a piece of code, it will help.
    Here is a javascript example:
    // me and tag are registrerBean done prior to calling the script
    var me = bsf.lookupBean ("me");
    var tag = bsf.lookupBean ("tag");
    // id is a String
    var id = tag.getProperty("id");
    // topComponent is a Swing JFrame
    var topComponent = me.getComponent("frame-id");
    =======================
    The test I have done with the BSF Perl is only:
    print 'Hello world.';
    which is consumed and show nothing in my Console, because I saw that the STDOUT is redirect.

    I hope I can allow people to use your BSF Perl if I see more the picture.

    Thanks for the good work.

    Pierre Morel

     
    • Don Schwarz

      Don Schwarz - 2004-05-20

      This should work in Perl just as it would in any other language:

      my $me = $bsf->lookupBean ("me");
      my $tag = $bsf->lookupBean ("tag");
      my $id = $tag->getProperty("id");
      my $topComponent = $me->getComponent("frame-id");

      As for STDOUT being redirected: yes, it is.  The real STDIN and STDOUT are being used to send method call requests/responses between Perl and Java, so STDOUT is redirected to STDERR.  "print STDOUT" and "print STDERR" should be equivalent, and should both end up in your process's real standard error stream.  If you're writing to STDOUT and not seeing it, make sure that you're capturing stderr, and try unbuffering STDOUT from Perl ("$|++").  Let me know if you're still having problems.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.