• Select a language



Java* and Python*, Together at Last
Page & Feed Options
Print this
Bookmark This
Digg this | Add to your del.icio.us account
Table of Contents

Conclusion & Resources
That's really all there is to using Jython. It's great for creating quick prototypes, scripts for cleanup, and it even permits incorporating interpretive environments for end users to play. The trick is just learning the different syntax for the Jython statements. For help there, be sure to check out the two available books on Jython: Jython for Java Programmers from New Riders and Jython Essentials from O'Reilly.

To wrap things up, here is the improved version of the source code:

# file list.py

from java.awt import Frame, BorderLayout, Button, List, TextField, Color

from java.lang import System



frame = Frame("Hello, Jython", size=(200, 200),

  windowClosing = lambda e: System.exit(0))



text = TextField()

frame.add(text, BorderLayout.NORTH)



list = List()

frame.add(list, BorderLayout.CENTER)



button = Button("Add",

  background=Color.yellow,

  actionPerformed = lambda e: list.add(text.text))



frame.add(button, BorderLayout.SOUTH)

frame.show()


Here's what the program looks like:

Figure 2. Hello, Jython
Resources
Jython Home—Download, FAQ, and documentation.
http://www.jython.org/*

Python Home—Information on Python programming language syntax.
http://www.python.org/*

LifeOff*—Installer used by Jython 2.1.
http://liftoff.sourceforge.net/*

Jython for Java Programmers (New Riders)—Includes source listings and installation information.
http://www.newriders.com/books/*

Jython Essentials (O'Reilly)—Includes sample chapter and examples.
http://www.oreilly.com/catalog/jythoness*

* Intel provides Internet links in this document as a convenience to its customers. The linked sites are independent of Intel, and Intel does not warrant and cannot be responsible for their contents.
Prev1  2  3  4  5  Next

Page 4 of 5