In MIDP the GUI components can be divided into 'Screen' components and 'Item' compontents. The 'Screen' components take up the whole screen of the device and they cannot be added to other 'Screen' components. GameCanvas and Form are two screen components and you cannot add GameCanvas to Form. Only 'Item' compontents can be added to a Form.
CustomItem provides a method 'paint(Graphics g)', which is called every time the component has to be repainted. In this method you can draw the pen's trace.
Joined: Feb 26, 2005
Thank you very much Yuri.
I'm using the CustomItem but it has one (annoying) limitation as you said: One can't draw except in the paint(Graphics g), so there is no getGraphics() as in GameCanvas. I tried to go around it by keeping a reference to the Graphics object I obrain in paint(Graphics g) to use it outside, but as I expected, it just failed (No back-doors in J2ME). The problem is that I do need to draw the whole pen trajectory just to add a new segment so instead of an O(n) I'm forced to have O(n2)... Do anyone knows about a better berformence (even using external libraries but MIDP-2.0-compantible)? kAWT and kjava seems to target the PalmOS! I'm using te Sony-Ericsson-P900 as an emulator (Mobile devices tend to be less powerful than PDAs)...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com