wl

Unnamed repository; edit this file 'description' to name the repository.
git clone https://logand.com/git/wl.git/
Log | Files | Refs | LICENSE

commit 495d00355e3ca8a7f77c5ba0bf0a4aa356b1cd4f
parent e90f5e01b120169d78e65f2344779c181e189559
Author: tomas <tomas@logand.com>
Date:   Fri, 30 Oct 2009 23:29:51 +0100

swing examples added to git

Diffstat:
Aswing2.l | 28++++++++++++++++++++++++++++
Aswing3.l | 11+++++++++++
Aswing4.l | 31+++++++++++++++++++++++++++++++
Aswing5.l | 31+++++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/swing2.l b/swing2.l @@ -0,0 +1,28 @@ +# http://www.java2s.com/Code/Java/Language-Basics/InvokemethodthroughJavaReflectionAPI.htm + +(import javax.swing JFrame JButton JLabel) +(import java.awt Container BorderLayout) +(import java.awt.event ActionListener) + +(setq F (jnew JFrame "Command Test")) +(setq B1 (jnew JButton "Tick")) +(setq B2 (jnew JButton "Tock")) +(setq B3 (jnew JButton "Quit")) +(setq L (jnew JLabel "Hello world")) +(setq C (F 'getContentPane)) + +(C 'setLayout (jnew BorderLayout)) +(C 'add B1 (jfield BorderLayout 'WEST)) +(C 'add B2 (jfield BorderLayout 'EAST)) +(C 'add B3 (jfield BorderLayout 'NORTH)) +(C 'add L (jfield BorderLayout 'SOUTH)) + +(de b1 @ (L 'setText (pack "tick " (str (rest))))) +(de b2 @ (L 'setText (pack "tock " (str (rest))))) + +(B1 'addActionListener (jproxy NIL 'b1 ActionListener)) +(B2 'addActionListener (jproxy T 'b2 ActionListener)) +(B3 'addActionListener (jproxy NIL 'bye ActionListener)) + +(F 'pack) +(F 'show) diff --git a/swing3.l b/swing3.l @@ -0,0 +1,11 @@ +(import javax.swing JFrame) +(import javax.swing JLabel) + +(setq F (jnew JFrame "HelloWorldSwing")) +(setq L (jnew JLabel "Hello World")) +(setq C (F 'getContentPane)) + +(C 'add L) +(F 'setDefaultCloseOperation (jfield JFrame 'EXIT_ON_CLOSE)) +(F 'pack) +(F 'setVisible true) diff --git a/swing4.l b/swing4.l @@ -0,0 +1,31 @@ +(import javax.swing JFrame JLabel JTextField JButton) +(import java.awt.event ActionListener) +(import java.awt Container BorderLayout) + +(setq W (jnew JFrame "Celsius Converter")) +(setq L (jnew JTextField)) +(setq C (jnew JLabel "Celsius")) +(setq B (jnew JButton "Convert")) +(setq F (jnew JLabel "Fahrenheit")) + +# (de b (E) +# (let X ((jclass 'java.lang.Double) 'parseDouble (L 'getText)) +# (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) ) +# # (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) ) + +(de b (E) + (job '((L . `L) (F . `F)) +# (let X (`(jclass 'java.lang.Double) 'parseDouble (L 'getText)) + (let X (jnum (L 'getText)) + (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) ) ) +# (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) ) + +(B 'addActionListener (jproxy NIL 'b ActionListener)) +(W 'setDefaultCloseOperation (jfield JFrame 'EXIT_ON_CLOSE)) +(W 'setLayout (jnew BorderLayout)) +(W 'add L (jfield BorderLayout 'NORTH)) +(W 'add C (jfield BorderLayout 'WEST)) +(W 'add F (jfield BorderLayout 'EAST)) +(W 'add B (jfield BorderLayout 'SOUTH)) +(W 'pack) +(W 'show) diff --git a/swing5.l b/swing5.l @@ -0,0 +1,31 @@ +(import javax.swing JFrame JLabel JTextField JButton) +(import java.awt.event ActionListener) +(import java.awt GridLayout) + +(setq W (jnew JFrame "Celsius Converter")) +(setq L (jnew JTextField)) +(setq C (jnew JLabel "Celsius")) +(setq B (jnew JButton "Convert")) +(setq F (jnew JLabel "Fahrenheit")) + +# (de b (E) +# (let X ((jclass 'java.lang.Double) 'parseDouble (L 'getText)) +# (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) ) +# # (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) ) + +(de b (E) + (job '((L . `L) (F . `F)) +# (let X (`(jclass 'java.lang.Double) 'parseDouble (L 'getText)) + (let X (jnum (L 'getText)) + (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) ) ) +# (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) ) + +(B 'addActionListener (jproxy NIL 'b ActionListener)) +(W 'setDefaultCloseOperation (jfield JFrame 'EXIT_ON_CLOSE)) +(W 'setLayout (jnew GridLayout 2 2 3 3)) +(W 'add L) +(W 'add C) +(W 'add B) +(W 'add F) +(W 'setSize 300 80) +(W 'setVisible true)