O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using an Applet as a Container

Because you can use applets interchangeably with panels they're easy to test and debug. Debugging is even easier if the applet runs as a standalone application rather than within a browser. Let's run one from the interactive interpreter.

Import Applet, List, and Frame.

>>> from java.applet import Applet
>>> from java.awt import List, Frame

Create an instance of Applet and List; add the List instance to the applet instance.

>>> applet = Applet()
>>> list = List()
>>> applet.add(list)
java.awt.List[list0,0,0,0x0,invalid,selected=null]

Create an instance of Frame; add applet to it.

 >>> frame = Frame("Frame that contains the Applet") >>> frame.add(applet) java.applet.Applet[panel0,0,0,0x0,invalid,layout=java.awt.FlowLayout] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required