wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes how to create a textfield in canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to create a textfield in canvas" Watch "how to create a textfield in canvas" New topic

how to create a textfield in canvas

Bikesh maharjan

Joined: Mar 04, 2011
Posts: 1

can anybody tell me how to create a textfield in canvas??

Giovanni Lima

Joined: Mar 08, 2011
Posts: 13
I belive that isnt possible, because, textfield can only be attached in form component..
Look for JME documentation to figure out more details
Muzaffar Shah Khan

Joined: Feb 13, 2010
Posts: 7
Yes its not possible to use form and canvas components together ! According to me but there must be some other way out for it i guess.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

Technically, you can't create a textfield in a canvas, but I think you can create a textfield overlay on a canvas. By which I mean that the 2 controls (textfield and canvas) occupy the same part of the screen (layout manager permitting), but the Z order of the textfield puts it in front of the canvas.

Just be careful when implementing the paint code so that the canvas does, in fact render behind the text control!

Customer surveys are for companies who didn't pay proper attention to begin with.
Vijay Dogra

Joined: Sep 16, 2004
Posts: 22
Yes, You can create textfield using Canvas, though its quite lengthy and difficult

1. Override the paint method
2. Draw rectangle and use the font to be used to type
3. Override keypressed event and check which key is pressed and repaint it.

These are just guideliness.
Vijay Dogra

Joined: Sep 16, 2004
Posts: 22
Check this link

Don't get me started about those stupid light bulbs.
subject: how to create a textfield in canvas
Similar Threads
Help on KeyPressed()?
Gui components alignment
I want to use canvas to read input from key pad!
TextField background color inconsistencies
Canvas class