Last active
October 15, 2015 05:49
-
-
Save alcidesfp/2492398 to your computer and use it in GitHub Desktop.
Ejemplo Swing Kawa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- coding:utf-8; mode:Scheme -*- | |
"Shows howto use Java Swing classes in Kawa Scheme" | |
(define-alias JLabel javax.swing.JLabel) | |
(define-alias JButton javax.swing.JButton) | |
;;======================================================================== | |
(define-simple-class SimpleFrame (javax.swing.JFrame) | |
;; members | |
(label ::JLabel init: (JLabel "Swing Application in Kawa")) | |
(button init: (JButton "Click Me!" | |
action-listener: (lambda (event)(on-click-btn)))) | |
;;---------------------------------------------------------------------- | |
;; methods | |
((*init*) ;constructor | |
(invoke-special javax.swing.JFrame (this) '*init* "Hello Swing in Kawa") | |
(format #t "Initializing ...~%") | |
;; initialize UI | |
(add label java.awt.BorderLayout:CENTER) | |
(add button java.awt.BorderLayout:SOUTH) | |
(setDefaultCloseOperation javax.swing.JFrame:EXIT_ON_CLOSE) | |
(pack)) | |
;;---------------------------------------------------------------------- | |
((on-click-btn) ;event handler | |
(label:setText "You clicked the button!"))) | |
;;======================================================================== | |
(define (main) | |
(let ((frame (SimpleFrame))) | |
(frame:setVisible #t))) | |
(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, de hecho las definiciones de clases en Kawa no son inmutables, esta es una diferencia con respecto a Clojure AFAIK.