From: Scott H. <sl...@ho...> - 2001-08-31 16:22:53
|
I am trying to create a jython applet. I am running Windows 2000 pro = with Sun's JDK 1.3.1 and I have tried both Jython 2.0 and 2.1a3. My = code runs fine when I execute it with Jython, but when comiling it into = the applet with (I have only one .py file named dlClient.py): jython --compiler javac --all --jar downloadClient.jar *.py The .jar is created, but it gives a warning about using a deprecated = API. Then when I try to execute it with the appletviewer, I get an = error that says: java.lang.ClassCastException: dlClient Can anyone tell me what I am doing wrong? Below, I have posted the code = for the .py file as well. from java import applet from java.awt import Color,Label,Button,GridLayout,Label from urllib import urlretrieve import time class downloadClient(applet.Applet): def init(self): try: self.setLayout(GridLayout(0,1)) self.title =3D self.add(Label('Download Test', Label.CENTER)) self.title.setBackground(Color.blue) self.title.setForeground(Color.white) self.add(Label('Beginning Download ...')) # this file is 45.7k in size self.startTime =3D time.time() rValue =3D urlretrieve("http://localhost/reports/detail.pdf") rValue =3D urlretrieve("http://localhost/reports/detail.pdf") rValue =3D urlretrieve("http://localhost/reports/detail.pdf") self.endTime =3D time.time() self.elapsedTime =3D int(self.endTime - self.startTime) self.kPerSec =3D int(137.1/self.elapsedTime) self.add(Label('Download Complete')) self.add(Label('Amount Downloaded: 137.1 KB')) self.add(Label('Time Elapsed: ' + str(self.elapsedTime) + ' = seconds')) self.totalSpeed =3D self.add(Label('Total Speed: ' + = str(self.kPerSec) + ' KB/Sec')) self.totalSpeed.setBackground(Color.yellow) #self.totalSpeed.setForeground(Color.blue) except: pass if __name__ =3D=3D '__main__':=20 import pawt pawt.test(downloadClient()) |