Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 17:35, 24 October 2007.

Hello World no Java ME

From Forum Nokia Wiki

Original: Hello World in Java ME

Se você deseja aprender uma nova linguage, o primeiro programa é o sempre e clássico "Heelo World!".

Este programa cria um novo form com um item string e um botão de sair (exit).

Image:helloworld.png

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) {
                exitMIDlet();
            }
        }
    }
        
    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);        
        display.setCurrent(form);
    }
    
    // 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() {
        display.setCurrent(null);
        notifyDestroyed();
    }
    
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
Problem: Java.Security.SecureRandom does not exists AyedSQ Mobile Java Networking & Messaging & Security 8 2006-10-04 21:52
Finding mobile location with API? SanjayKhuntia Location Based Services and Navigation 14 2008-08-24 06:17
How to receive message from mobile to pc using "Simplewire" ? lkwan2001 General Messaging 3 2006-03-13 16:58
Carbide.j 1.5 released peterblazejewicz Mobile Java Tools & SDKs 21 2007-05-15 08:38
Novice require help susheel1 General Symbian C++ 5 2007-05-23 06:59
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX