On and off over the past several months, I've been working on a jython application that will eventually be deployed as an applet.  In order to best take advantage of jython, I've been working with the interpreter instead of actually compiling an applet;  I've essentially got a main.py that creates a canvas, and my main controller object, and hooks them up like this:

gtiWin = swing.JFrame("gti")
gtiWin.size = (400, 400)

appController = DocumentController(gtiWin, gtiWin.contentPane)

gtiWin.pack()
gtiWin.show()

And here's what DocumentController does with the JFrame that I pass it:

    def __init__(self, mainWindow, wrapperPane):
        # snip
        self.mainWindow = mainWindow
        self.wrapperPane = wrapperPane
        self.wrapperPane.layout = awt.BorderLayout()

after which it adds some GUI elements to self.wrapperPane.  So far, so good. 

Now, I want to make a simple applet that will do the same thing as my main.py, but I'm not sure where to begin.  Here's a stab at it:

class AppletMain(JApplet):
    def createGUI(self):
        self.panel = JPanel()
        self.contentPane.add(self.panel)
        appController = DocumentController(panel, panel.contentPane)
        panel.pack()
        panel.show()

    def init(self):
        self.createGUI()

    def __init__(self):
        self.createGUI()

Note that I'm not at all sure whether I need to implement init, __init__, or both (I seem to have seem conflicting implementations in various examples).  Also, I don't know if JPanel is the class I want to use here;  I want to just have the applet embedded in the page.  Maybe I should pass along the applet itself, along with its contentPane:

    def createGUI(self):
        appController = DocumentController(self, self.contentPane)
        self.pack()
        self.show()

Needless to say, neither of these approaches work for me.  I just get an "Applet AppletMain notinited" message in the status line of my browser (Safari).  I know that my jython environment (using 2.2alpha1) is working, and that the html for loading the applet is valid, since I can successfully compile a simpler "Hello world" applet and deploy it in the same page.  It's not a matter of the browser caching a bad version either, I've quit and restarted each time I test.

So, my main questions are:

- This idea of mine, that a simple outer shell should create or acquire some sort of canvas to pass into a main controller (who doesn't need to know where the canvas really comes from):  is this a reasonable thing to do?
- Assuming the answer to the first question is "yes" or at least "maybe", why are my approaches with the applet failing?  Is there anyway I can debug applet startup?

--
// jack
// http://www.nuthole.com