public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* JavaFx and the Kawa REPL
@ 2016-01-25 12:43 ben yakawp
  2016-01-25 17:47 ` Per Bothner
  0 siblings, 1 reply; 2+ messages in thread
From: ben yakawp @ 2016-01-25 12:43 UTC (permalink / raw)
  To: kawa

hi

I try to run the following example from kawas website:

~~~~~~~~~~~~
(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))))
~~~~~~~~~~~~~
source:
https://www.gnu.org/software/kawa/Building-JavaFX-applications.html


This example works only when running as script, not when loaded from a
repl.

The line makes the repl unresponsive: "(javafx-application)"

Is this normal behaviour or how can I prepare the "stage" in the repl.

Regards
Ben

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

* Re: JavaFx and the Kawa REPL
  2016-01-25 12:43 JavaFx and the Kawa REPL ben yakawp
@ 2016-01-25 17:47 ` Per Bothner
  0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2016-01-25 17:47 UTC (permalink / raw)
  To: ben yakawp, kawa



On 01/25/2016 04:43 AM, ben yakawp wrote:
> This example works only when running as script, not when loaded from a
> repl.
>
> The line makes the repl unresponsive: "(javafx-application)"
>
> Is this normal behaviour or how can I prepare the "stage" in the repl.

It's normal.  The  problem is that JavaFX (like Swing and most other
GUI toolkits) is single-threaded, and everything GUI-related must
happen on the JavaFX thread.  That is why in JavaFX programs
you'll see a lot of calls to Platform.runLater - and why it's very
easy to hang JavaFX programs if they're not carefully written.

The definitions in javafx-def are fairly simple, and make no attempt
to deal with the threading issues.  It might be worthwhile to
attempt to design a JavaFX wrapper API that makes it easier (and
less error-prone) to co-ordinate between the JavaFX thread and
one or more user threads.

I wrote a REPL based on JavaFX (using WebView): See
https://github.com/PerBothner/JWebTerminal
However, I've abandoned that project in favor of DomTerm: http://domterm.org/
I'm working om some neat REPL features using DomTerm - and I hope to
allow friendlier GUI programming from Kawa using related Web technologies.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

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

end of thread, other threads:[~2016-01-25 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 12:43 JavaFx and the Kawa REPL ben yakawp
2016-01-25 17:47 ` Per Bothner

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).