Possible Duplicate:
Is this possible to use lwuit.Dialog with javax.microedition.lcdui.Canvas in wireless toolkit 2.5.2?
I created a canvas to write contents when I press mobile keys(for Example if I press "A" it will be written on the screen using paint function). Now I want to show a dialog or PopUp window when I press any key from mobile. Is it possible to show dialog when am using Canvas?
say some example,
public class Mycanvas extends Canvas implement ActionListener
{
Dialog dialog=new Dialog();
}
Ok, I think you must do that. The right thing in LWUIT is using Dialog
.
Create a Dialog
using new
. i.e. Dialog d = new Dialog()
The next step is filling the title and body with Dialog.setTitle(String text)
or putting something inside the Dialog
's layout.
When your Dialog
is ready to be shown, you must call to Dialog.show()
and when you want to remove it, call to Dialog.dispose()
Take a look here
Is this possible to use lwuit.Dialog with javax.microedition.lcdui.Canvas in wireless toolkit 2.5.2?
If it is for debugging purpose you can use Alert instead. Here's an example how you can use Alert:
//you need to import javax.microedition.lcdui;
Alert alert = new Alert("Info", "Here's the key code/string", null, AlertType.INFO);
alert.setTimeout(3000); // for 3 seconds
display.setCurrent(alert, yourcanvasname); // so that it goes to back to your canvas after displaying the alert
Alert works fine with both forms and canvases.