Transforming the Address Book Application into an Applet

What we're going to do is convert AddressMain, which is currently a form, into an applet. Later we'll make changes to AddressModel so that it can deal with URLs instead of files. This means that it will be able to read and write to any files to which it refers, including any file transmitted over the HTTP protocol.

Changes to AddressMain

First let's make it so AddressMain derives from an applet instead of a frame.

class AddressMain(JApplet):

Now let's add the __init__ and __destroy__ methods. __init__ gives us access to the database, which we need to initialize AddressModel. __destroy__ calls AddressModel's writeAddress() function, which writes addresses out to a file (if the protocol ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.