[Jython-dev] Coercion or cast trouble with Jython and Swing...
by other posts by this author
Apr 30 2003 3:43PM messages near this date
[Jython-dev] Jython Console with Code Completion
|
Re: [Jython-dev] Coercion or cast trouble with Jython and Swing...
Greetings,
I'm having troubles with type coercion / casting with java.awt.Graphics objects:
I want to use the drawPolygon() method but at runtime JPanel.getGraphics()
returns a sun.awt.windows.WGraphics and the Jython interpreter try to
cast it into a sun.java2d.SunGraphics2D. I never had such problems with Java. I
don't know what to do. Moving back to Java programming ? Jython is just so GREAT
! I can't go back to Java !!!
Remy Moueza
class JDisplay ( JPanel, MouseListener, MouseMotionListener ):
...
def display_poly ( self, poly, screen ):
...
x_values = []
y_values = []
for point in poly.points :
x, y = screen.output ( point )
x_values.append ( x )
y_values.append ( y )
gc = self.getGraphics ()
print gc
x_coord = array ( x_values, "i" )
y_coord = array ( y_values, "i" )
gc.drawPolygon ( x_coord, len( x_values ), y_coord, len( y_values ))
Here is the error message :
sun.awt.windows.WGraphics # -> print gc
Traceback (innermost last):
File "C:\lecteurD\monDev\3Dmoteur\python\JAffichage.py", line 0, in main
File "C:\lecteurD\monDev\3Dmoteur\python\JAffichage.py", line 0, in display
File "C:\lecteurD\monDev\3Dmoteur\python\JAffichage.py", line 0, in
display_facette
TypeError: drawPolygon(): 1st arg can't be coerced to sun.java2d.SunGraphics2D
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
Jython-dev mailing list
Jython-dev@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-dev
Thread:
Oti
|