commit d7c77a34fc8fea0dbc617485cc903bee7ef62303 parent 0a164a8584c1b329e12f4cfb540401bfd0521800 Author: tomas <tomas@logand.com> Date: Sat, 31 Oct 2009 01:34:23 +0100 example lunar phases added: swing6.l + image0-7.jpg Diffstat:
A | image0.jpg | | | 0 | |
A | image1.jpg | | | 0 | |
A | image2.jpg | | | 0 | |
A | image3.jpg | | | 0 | |
A | image4.jpg | | | 0 | |
A | image5.jpg | | | 0 | |
A | image6.jpg | | | 0 | |
A | image7.jpg | | | 0 | |
A | swing6.l | | | 54 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
9 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/image0.jpg b/image0.jpg Binary files differ. diff --git a/image1.jpg b/image1.jpg Binary files differ. diff --git a/image2.jpg b/image2.jpg Binary files differ. diff --git a/image3.jpg b/image3.jpg Binary files differ. diff --git a/image4.jpg b/image4.jpg Binary files differ. diff --git a/image5.jpg b/image5.jpg Binary files differ. diff --git a/image6.jpg b/image6.jpg Binary files differ. diff --git a/image7.jpg b/image7.jpg Binary files differ. diff --git a/swing6.l b/swing6.l @@ -0,0 +1,54 @@ +# http://life.csu.edu.au/java-tut/uiswing/learn/example-1dot4/LunarPhases.java +# http://life.csu.edu.au/java-tut/uiswing/learn/example-1dot4/images/image0.jpg + +(import javax.swing JFrame JPanel JLabel JComboBox BoxLayout BorderFactory ImageIcon) +(import java.awt.event ActionListener) + +(setq I + (fmap '((X) (cons X (jnew ImageIcon (pack "image" X ".jpg")))) '(0 1 2 3 4 5 6 7)) ) + +(JFrame 'setDefaultLookAndFeelDecorated true) +(setq F (jnew JFrame "Lunar Phases") + S (jnew JPanel) + D (jnew JPanel) + M (jnew JPanel) + L (jnew JLabel) + C (jnew JComboBox + (jvector "New" "Waxing Crescent" "First Quarter" "Waxing Gibbous" + "Full" "Waning Gibbous" "Third Quarter" "Waning Crescent" ) ) ) + +(de onCombo (M E) + (job '((L . `L) (C . `C) (I . `I)) + (when (= "comboBoxChanged" (E 'getActionCommand)) + (L 'setIcon (cdr (assoc (jnum (C 'getSelectedIndex)) I))) ) ) ) + +(F 'setDefaultCloseOperation (jfield JFrame 'EXIT_ON_CLOSE)) +(F 'setContentPane M) +(M 'setLayout (jnew BoxLayout M (jfield BoxLayout 'PAGE_AXIS))) +(M 'setBorder (BorderFactory 'createEmptyBorder 5 5 5 5)) +(M 'add S) +(M 'add D) +(L 'setHorizontalAlignment (jfield JLabel 'CENTER)) +(L 'setVerticalAlignment (jfield JLabel 'CENTER)) +(L 'setVerticalTextPosition (jfield JLabel 'CENTER)) +(L 'setHorizontalTextPosition (jfield JLabel 'CENTER)) +(L 'setBorder (BorderFactory 'createCompoundBorder + (BorderFactory 'createLoweredBevelBorder) + (BorderFactory 'createEmptyBorder 5 5 5 5) ) ) +(L 'setBorder (BorderFactory 'createCompoundBorder + (BorderFactory 'createEmptyBorder 0 0 10 0) + (L 'getBorder) ) ) +(C 'setSelectedIndex 3) +(L 'setIcon (cdr (assoc 2 I))) +(C 'addActionListener (jproxy NIL 'onCombo ActionListener)) +(L 'setText "") +(S 'setBorder (BorderFactory 'createCompoundBorder + (BorderFactory 'createTitledBorder "Select Phase") + (BorderFactory 'createEmptyBorder 5 5 5 5) ) ) +(D 'setBorder (BorderFactory 'createCompoundBorder + (BorderFactory 'createTitledBorder "Display Phase") + (BorderFactory 'createEmptyBorder 5 5 5 5) ) ) +(D 'add L) +(S 'add C) +(F 'pack) +(F 'setVisible true)