public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* javafx
@ 2017-05-13 12:58 Chris Vine
  2017-05-13 16:31 ` javafx Per Bothner
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Vine @ 2017-05-13 12:58 UTC (permalink / raw)
  To: Kawa mailing list

There seems to be a problem with the 'javafx-scene' macro in kawa-2.4.

First, the example at
https://www.gnu.org/software/kawa/Building-JavaFX-applications.html#idm139760384873792
fails to size the button correctly when compared with kawa-2.1.9.  The
same occurs with kawa-2.3 (I have not tested with kawa-2.2).

Curiously, taking this more complex example:

*****************
(require 'javafx-defs)
(javafx-application)

(javafx-scene
 title: "Hello Button"
 width: 600 height: 450
 (Button
  text: "Click Me"
  layout-x: 25
  layout-y: 40
  on-action: (lambda (e) (format #t "Event: ~s~%~!" e)))
 (Button
  text: "Click Me 2"
  layout-x: 25
  layout-y: 70
  on-action: (lambda (e) (format #t "Event: ~s~%~!" e)))
 (Button
  text: "Click Me 3"
  layout-x: 25
  layout-y: 100
  on-action: (lambda (e) (format #t "Event: ~s~%~!" e))))
*****************

kawa-2.3 works correctly (the buttons are correctly sized), whereas
kawa-2.4 fails to run the code, with this error:

Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to javafx.scene.Node
	at gnu.kawa.javafx.MakeScene.build(MakeScene.scm:54)
	at javafx-test2.run(javafx-test2.kawa:10008)
	at gnu.kawa.javafx.KawaJavafxApplication.start(defs.scm:65)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
	... 1 more

If you avoid the javafx-scene macro, and set up the scene by hand,
all seems to work fine with any kawa-2 version.

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: javafx
  2017-05-13 12:58 javafx Chris Vine
@ 2017-05-13 16:31 ` Per Bothner
  2017-05-13 17:13   ` javafx Chris Vine
  0 siblings, 1 reply; 3+ messages in thread
From: Per Bothner @ 2017-05-13 16:31 UTC (permalink / raw)
  To: Chris Vine, Kawa mailing list

On 05/13/2017 05:58 AM, Chris Vine wrote:
> There seems to be a problem with the 'javafx-scene' macro in kawa-2.4.
> 
> First, the example at
> https://www.gnu.org/software/kawa/Building-JavaFX-applications.html#idm139760384873792
> fails to size the button correctly when compared with kawa-2.1.9.  The
> same occurs with kawa-2.3 (I have not tested with kawa-2.2).

This was a bug introduced here:

2016-06-26  Per Bothner  <per@bothner.com>

	* MakeScene.scm (MakeScene): Don't create Group until actually needed.

I checked in a fix, in both the master and kawa-2.4 branches.
  
> kawa-2.3 works correctly (the buttons are correctly sized), whereas
> kawa-2.4 fails to run the code, with this error:
> 
> Exception in Application start method
> java.lang.RuntimeException: Exception in Application start method
> 	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
> 	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to javafx.scene.Node
> 	at gnu.kawa.javafx.MakeScene.build(MakeScene.scm:54)
> 	at javafx-test2.run(javafx-test2.kawa:10008)
> 	at gnu.kawa.javafx.KawaJavafxApplication.start(defs.scm:65)
> 	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
> 	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
> 	at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
> 	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
> 	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
> 	at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
> 	... 1 more

I was able to reproduce it before, though only on the old 2.4 branch.
It seems to have gone away - though it might be JDK or other environment issues.
Let me know if you still experience it with the kawa-2.4 branch.
Of course, you could also switch to the master (formerly 'invoke') branch;
I doubt I'll make another 2.4.x release.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: javafx
  2017-05-13 16:31 ` javafx Per Bothner
@ 2017-05-13 17:13   ` Chris Vine
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Vine @ 2017-05-13 17:13 UTC (permalink / raw)
  To: kawa, Per Bothner

On Sat, 13 May 2017 09:30:35 -0700
Per Bothner <per@bothner.com> wrote:
> On 05/13/2017 05:58 AM, Chris Vine wrote:
> > There seems to be a problem with the 'javafx-scene' macro in
> > kawa-2.4.
> > 
> > First, the example at
> > https://www.gnu.org/software/kawa/Building-JavaFX-applications.html#idm139760384873792
> > fails to size the button correctly when compared with kawa-2.1.9.
> > The same occurs with kawa-2.3 (I have not tested with kawa-2.2).  
> 
> This was a bug introduced here:
> 
> 2016-06-26  Per Bothner  <per@bothner.com>
> 
> 	* MakeScene.scm (MakeScene): Don't create Group until
> actually needed.
> 
> I checked in a fix, in both the master and kawa-2.4 branches.
>   
> > kawa-2.3 works correctly (the buttons are correctly sized), whereas
> > kawa-2.4 fails to run the code, with this error:
> > 
> > Exception in Application start method
> > java.lang.RuntimeException: Exception in Application start method
> > 	at
> > com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
> > at
> > com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
> > at java.lang.Thread.run(Thread.java:745) Caused by:
> > java.lang.ClassCastException: java.util.ArrayList cannot be cast to
> > javafx.scene.Node at
> > gnu.kawa.javafx.MakeScene.build(MakeScene.scm:54) at
> > javafx-test2.run(javafx-test2.kawa:10008) at
> > gnu.kawa.javafx.KawaJavafxApplication.start(defs.scm:65) at
> > com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
> > at
> > com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
> > at
> > com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
> > at java.security.AccessController.doPrivileged(Native Method) at
> > com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
> > at
> > com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
> > at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at
> > com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139) ...
> > 1 more  
> 
> I was able to reproduce it before, though only on the old 2.4 branch.
> It seems to have gone away - though it might be JDK or other
> environment issues. Let me know if you still experience it with the
> kawa-2.4 branch. Of course, you could also switch to the master
> (formerly 'invoke') branch; I doubt I'll make another 2.4.x release.

I posted this mainly to alert you to the issue rather than needing a
fix myself, as I use your binary distribution.  Congratulations on the
job you have done with kawa: I find that programming Java is not a
pleasant experience (its like being in an Austin Powers time warp), so
it is good to have something nice to program for on the JVM.

As regards javafx I prefer to reproduce the kawa definition of
javafx-application (which also injects javafx-stage) and
KawaJavafxApplication directly into a separate importable file and build
the scene myself rather than use the javafx-scene macro.

Apart from anything else, javafx-defs aliases a random set of other
definitions such as Button, Node and FlowPane which can clash with the
user code's own imports (if any) and I find it easier to avoid
javafx-scene altogether.  But I came across the problem and thought I
would let you know.

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-13 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-13 12:58 javafx Chris Vine
2017-05-13 16:31 ` javafx Per Bothner
2017-05-13 17:13   ` javafx Chris Vine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).