Python문법으로, Java객체들을 불러다가 쓸수 있다. 전형적인 ProgrammingLanguage의 HybridTheCreativeOntology.
관련자료
JythonEssentials에 나오는 Swing기초예제.
1 import java.lang as lang
2 import javax.swing as swing
3 import java.awt as awt
4
5 names = ["Groucho","Chico","Harpo"]
6 quotes = {"Groucho": "Say the secret word",
7 "Chico": "Viaduct?",
8 "Harpo": "HONK!"}
9
10 def buttonPressed(event):
11 field.text = quotes[event.source.text]
12
13 def exit(event):
14 lang.System.exit(0)
15
16 def createButton(name):
17 return swing.JButton(name, preferredSize=(100,20),
18 actionPerformed = buttonPressed)
19
20 win = swing.JFrame("Welcome to Jython", size=(100,20), windowClosing=exit)
21 win.contentPane.layout = awt.FlowLayout()
22
23 field = swing.JTextField(preferredSize=(200,20))
24 win.contentPane.add(field)
25
26 buttons = [createButton(each) for each in names]
27 for eachButton in buttons:
28 win.contentPane.add(eachButton)
29
30 win.pack()
31 win.show()