Form fr = new Form("Recognizer Form"); Display.getDisplay(this).setCurrent(can); fr.append(new TextField); // fr.append(canv);
But it doesn't work (since append doesn't take a Canvas parameter).
What should I do in order to display them togother?
I tried to use a CustomItem instead of GameCanvas but it doesn't contain the getGraphics() method neccessary for drawing the pen's trace.
Do anyone has an idea?
Thanks in Advance.
SCJP for J2SE 5.0 (beta)<br />SCJA (beta)
Joined: Sep 13, 2003
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)...