Re: [jruby-user] JRubyFX

Thomas E Enebo <[email protected]> Wed, 29 Apr 2015 13:36:46 -0500
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CAL5zZVmFqhoKjCzpLR9z8h4usTGGJLE3DNwGPUja-XTd2e-wMQ@mail.gmail.com>
--001a11c36034f302920514e142d8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I am less of a help for JS but if you see how WebView is defined above you
can perhaps do he same thing for ChangeListener is your JS code is barfing
because it does not know what that type is:

var ChangeListener =3D Java.type("javafx.beans.value.ChangeListener");

-Tom

On Wed, Apr 29, 2015 at 1:32 PM, Rodrigo Botafogo <
[email protected]> wrote:

> Hi Tom,
>
> Not sure I follow... so, the following function is defined inside a
> javascript file and not in a JRuby script.  I can=C2=B4t do this implicit
> coercion.  I think I should load the ChangeListener interface and make it
> available to javascript.  I=C2=B4m still learning all this, so I might ju=
st be
> confused.  If this is any help, I=C2=B4m just trying to follow the blog:
> https://blogs.oracle.com/nashorn/entry/porting_from_the_browser_to, but
> instead of using jjs, I=C2=B4m driving nashorn through JRuby.
>
>
> function WebViewWrapper(onload) {
>     var This =3D this;
>     var WebView =3D Java.type("javafx.scene.web.WebView");
>     var webview =3D new WebView();
>
>     This.webview =3D webview;
>     This.engine =3D webview.engine;
>     This.window =3D undefined;
>     This.document =3D undefined;
>
>     // Make sure the JavaScript is enabled.
>     This.engine.javaScriptEnabled =3D true;
>
>     // Complete initialization when page is loaded.
>     This.engine.loadWorker.stateProperty().addListener(new
> ChangeListener() {
>         changed: function(value, oldState, newState) {
>             if (newState =3D=3D Worker.State.SUCCEEDED) {
>                 This.document =3D
> wrap(This.engine.executeScript("document"));
>                 This.window =3D wrap(This.engine.executeScript("window"))=
;
>
>                 // Call users onload function.
>                 if (onload) {
>                     onload(This);
>                 }
>             }
>         }
>     });
>
>
> Thanks....
>
> 2015-04-29 15:20 GMT-03:00 Thomas E Enebo <[email protected]>:
>
> javafx.beans.value.ChangeListener is an interface so with implicit closur=
e
>> coercion you should be able to:
>>
>>
>> ```ruby
>> This.engine.load_worker.state_property.add_listener do |observable,
>> old_value, new_value|
>>   #...
>> end
>> ```
>>
>> -Tom
>>
>>
>> On Wed, Apr 29, 2015 at 11:42 AM, Rodrigo Botafogo <
>> [email protected]> wrote:
>>
>>> Hello....
>>>
>>> Sorry if this isn=C2=B4t the right place to post questions about JRubyF=
X.
>>>
>>> I=C2=B4m trying to write a JRubyFX application.  I=C2=B4m following a p=
ost from
>>> Oracle to try to learn JavaFX and JRubyFx.  In the post, in a js file t=
here
>>> is the following lines:
>>>
>>>  // Complete initialization when page is loaded.
>>>   This.engine.loadWorker.stateProperty().addListener(new ChangeListener=
() {
>>>
>>>
>>> ChangeListener() is not found when I run the application.  I understand
>>> that I should load javafx/beans, but I don=C2=B4t know how to do this w=
ith
>>> JRubyFX.  Can anybody help me here or point to the right list to ask th=
is
>>> question?
>>>
>>> Thanks
>>> --
>>> Rodrigo Botafogo
>>>
>>>
>>>
>>>
>>
>>
>> --
>> blog: http://blog.enebo.com       twitter: tom_enebo
>> mail: [email protected]
>>
>
>
>
> --
> Rodrigo Botafogo
>
>
>
>


--=20
blog: http://blog.enebo.com       twitter: tom_enebo
mail: [email protected]

--001a11c36034f302920514e142d8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>I am less of a help for JS but if you see how We=
bView is defined above you can perhaps do he same thing for ChangeListener =
is your JS code is barfing because it does not know what that type is:<br><=
br></div>var ChangeListener =3D Java.type(&quot;javafx.beans.value.ChangeLi=
stener&quot;);<br><br></div>-Tom<br></div><div class=3D"gmail_extra"><br><d=
iv class=3D"gmail_quote">On Wed, Apr 29, 2015 at 1:32 PM, Rodrigo Botafogo =
<span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr">Hi Tom,<div><br></div><div>Not sure I=
 follow... so, the following function is defined inside a javascript file a=
nd not in a JRuby script.=C2=A0 I can=C2=B4t do this implicit coercion.=C2=
=A0 I think I should load the ChangeListener interface and make it availabl=
e to javascript.=C2=A0 I=C2=B4m still learning all this, so I might just be=
 confused.=C2=A0 If this is any help, I=C2=B4m just trying to follow the bl=
og:=C2=A0<a href=3D"https://blogs.oracle.com/nashorn/entry/porting_from_the=
_browser_to" target=3D"_blank">https://blogs.oracle.com/nashorn/entry/porti=
ng_from_the_browser_to</a>, but instead of using jjs, I=C2=B4m driving nash=
orn through JRuby.</div><div><br></div><div><br></div><div><div>function We=
bViewWrapper(onload) {</div><div>=C2=A0 =C2=A0 var This =3D this;</div><div=
>=C2=A0 =C2=A0 var WebView =3D Java.type(&quot;javafx.scene.web.WebView&quo=
t;);</div><div>=C2=A0 =C2=A0 var webview =3D new WebView();</div><div>=C2=
=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 This.webview =3D webview;</div><di=
v>=C2=A0 =C2=A0 This.engine =3D webview.engine;</div><div>=C2=A0 =C2=A0 Thi=
s.window =3D undefined;</div><div>=C2=A0 =C2=A0 This.document =3D undefined=
;</div><div>=C2=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 // Make sure the Ja=
vaScript is enabled.</div><div>=C2=A0 =C2=A0 This.engine.javaScriptEnabled =
=3D true;</div><span class=3D""><div>=C2=A0 =C2=A0=C2=A0</div><div>=C2=A0 =
=C2=A0 // Complete initialization when page is loaded.</div><div>=C2=A0 =C2=
=A0 This.engine.loadWorker.stateProperty().addListener(new ChangeListener()=
 {</div></span><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 changed: function(value, ol=
dState, newState) {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if =
(newState =3D=3D Worker.State.SUCCEEDED) {</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 This.document =3D wrap(This.engine.execu=
teScript(&quot;document&quot;));</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 This.window =3D wrap(This.engine.executeScript(&qu=
ot;window&quot;));</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 // Call users onload function.</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (onload) {</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 onload(This);</div><di=
v>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 }</div><div>=C2=A0 =C2=A0 });</div></div><div><br></div><div><br></div>=
<div>Thanks....</div></div><div class=3D"gmail_extra"><br><div class=3D"gma=
il_quote">2015-04-29 15:20 GMT-03:00 Thomas E Enebo <span dir=3D"ltr">&lt;<=
a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
</a>&gt;</span>:<div><div class=3D"h5"><br><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><=
div dir=3D"ltr"><div><div><div>javafx.beans.value.ChangeListener is an inte=
rface so with implicit closure coercion you should be able to:<br></div><di=
v><br><br></div>```ruby<br></div>This.engine.load_worker.state_property.add=
_listener do |<code>observable, old_value, new_value|<br>=C2=A0 #...<br></c=
ode></div><code>end<br></code><div><div>```<br><br></div><div>-Tom<br><br><=
/div></div></div><div class=3D"gmail_extra"><div><div><br><div class=3D"gma=
il_quote">On Wed, Apr 29, 2015 at 11:42 AM, Rodrigo Botafogo <span dir=3D"l=
tr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">ro=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr">Hello....=C2=A0<div><br></div><div>Sorry if this is=
n=C2=B4t the right place to post questions about JRubyFX. =C2=A0</div><div>=
<br></div><div>I=C2=B4m trying to write a JRubyFX application.=C2=A0 I=C2=
=B4m following a post from Oracle to try to learn JavaFX and JRubyFx.=C2=A0=
 In the post, in a js file there is the following lines:</div><div><br></di=
v><div><pre style=3D"margin-top:10px;margin-bottom:10px;color:rgb(85,85,85)=
;font-size:12px;line-height:18px"> // Complete initialization when page is =
loaded.
  This.engine.loadWorker.stateProperty().addListener(new ChangeListener()=
=C2=A0{</pre><pre style=3D"margin-top:10px;margin-bottom:10px;color:rgb(85,=
85,85);font-size:12px;line-height:18px"><br></pre><div>ChangeListener() is =
not found when I run the application.=C2=A0 I understand that I should load=
 javafx/beans, but I don=C2=B4t know how to do this with JRubyFX.=C2=A0 Can=
 anybody help me here or point to the right list to ask this question?</div=
><div><br></div><div>Thanks</div><span><font color=3D"#888888">-- <br><div>=
<div dir=3D"ltr">Rodrigo Botafogo<div><br><br><div><br></div></div></div></=
div>
</font></span></div></div>
</blockquote></div><br><br clear=3D"all"><br></div></div><span><font color=
=3D"#888888">-- <br><div>blog: <a href=3D"http://blog.enebo.com" target=3D"=
_blank">http://blog.enebo.com</a>=C2=A0 =C2=A0 =C2=A0=C2=A0 twitter: tom_en=
ebo<br>mail: <a href=3D"mailto:[email protected]" target=3D"_blank">tom.e=
[email protected]</a></div>
</font></span></div>
</blockquote></div></div></div><span class=3D"HOEnZb"><font color=3D"#88888=
8"><br><br clear=3D"all"><div><br></div>-- <br><div><div dir=3D"ltr">Rodrig=
o Botafogo<div><br><br><div><br></div></div></div></div>
</font></span></div>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature">blog: <a href=3D"http://blog.enebo.com" target=3D"_blank">http://bl=
og.enebo.com</a>=C2=A0 =C2=A0 =C2=A0=C2=A0 twitter: tom_enebo<br>mail: <a h=
ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a=
></div>
</div>

--001a11c36034f302920514e142d8--