Saturday, July 25, 2009

Swing Frame using Jython

from javax.swing import JButton, JFrame

class MyFrame(JFrame):
def __init__(self):
JFrame.__init__(self, "Hello Jython")
button = JButton("Hello", actionPerformed=self.hello)
self.add(button)

self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setSize(300, 300)
self.show()

def hello(self, event):
print "Hello, world!"

if __name__=="__main__":
MyFrame()

No comments: