source: trunk/source/examples/jfli/examples/swtdemo.lisp @ 11435

Last change on this file since 11435 was 11435, checked in by gb, 12 years ago

Rich Hickey's 'jfli' (Lisp<->Java) bridge, as of jfli091104.zip.
The file 'jni.lisp' is LispWorks?-specific FFI code; there'll need
to be something CCL-specific that exports the same interface.

Text files in the .zip were CRLF-terminated; hopefully, svn will
fix that ...

File size: 2.0 KB
Line 
1;Just load this from LispWorks menu
2;note works on Windows, some issues on OS X due to windowing conflict w/IDE
3(load "~/jfli/jni")
4(load "~/jfli/jfli")
5(use-package :jfli)
6(create-jvm 
7#+:macosx "-Djava.class.path=/Users/rich/swt/swt.jar:/Users/rich/swt/swt-pi.jar:User/rich/jfli/jfli.jar"
8 #+:macosx "-Djava.library.path=/Users/rich/swt"
9 #+:win32 "-Djava.class.path=/swt/swt.jar;/lisp/jfli.jar"
10 #+:win32 "-Djava.library.path=/swt"
11 )
12(enable-java-proxies)
13
14
15
16(def-java-class "org.eclipse.swt.widgets.Display")
17(def-java-class "org.eclipse.swt.widgets.Button")
18(def-java-class "org.eclipse.swt.widgets.Shell")
19(def-java-class "org.eclipse.swt.widgets.Listener")
20(def-java-class "org.eclipse.swt.SWT")
21
22(use-package "org.eclipse.swt")
23(use-package "org.eclipse.swt.widgets")
24
25
26(defun swt-demo ()
27  (let* ((display (new display.))
28         (shell (new shell. display
29                     :gettext "Using SWT from Lisp"
30                     (.setsize 300 200)
31                     (.setlocation 100 100)))
32         (button (new (button. this) shell *SWT.CENTER*
33                      :gettext "Call Lisp"
34                      (.addlistener *swt.selection*
35                       (new-proxy (listener.
36                                   (handleevent (event)
37                                     (declare (ignore event))
38                                     (setf (button.gettext this)
39                                           (format nil "~A ~A"
40                                                   (lisp-implementation-type)
41                                                   (lisp-implementation-version)))
42                                     nil))))
43                      (.setsize 200 100)
44                      (.setlocation 40 40))))
45    (declare (ignore button))
46    (shell.open shell)
47    (do ()
48        ((shell.isdisposed shell))
49      (unless (display.readanddispatch display)
50        (display.sleep display)))
51    (display.dispose display)))
52
53(mp:process-run-function "swt-proc" '() #'swt-demo)
54
Note: See TracBrowser for help on using the repository browser.