Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Hello World no Java ME

From Wiki
Jump to: navigation, search
Article Metadata

Por TK2000
Última alteração feita por lpvalente em 13 Dec 2013

Se você deseja aprender uma nova linguagem, o primeiro programa é o sempre e clássico "Hello World!". Este artigo mostra um programa que cria um novo form com um item string e um botão de sair (exit).


package helloworld;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class HelloWorldMidlet extends MIDlet implements CommandListener {
public HelloWorldMidlet() {
// Display (tela)
private Display display;
// Main form (form principal)
private Form form;
// For the message (para a mensagem)
private StringItem stringItem;
// For the exit command (para o comando de sair)
private Command exitCommand;
public void commandAction(Command command, Displayable displayable) {
if (displayable == form) {
if (command == exitCommand) {
public void startApp() {
// Create form (cria o form)
stringItem = new StringItem( "Hello", "Hello World!");
form = new Form( null, new Item[] {stringItem});
exitCommand = new Command( "Exit", Command.EXIT, 1);
form.addCommand( exitCommand);
form.setCommandListener( this);
// Get display for drawning (pega a tela para desenhar)
display = Display.getDisplay(this);
// Your MIDlet should not call pauseApp(),
// only system will call this life-cycle method
public void pauseApp() {
// Your MIDlet should not call destroyApp(),
// only system will call this life-cycle method
public void destroyApp(boolean unconditional) {
public void exitMIDlet() {
This page was last modified on 13 December 2013, at 23:17.
62 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.