Gostaria que alguém me passase um exemplo bastante simples de Midlet, algum exemplo que mostre alguma coisa no visor do celular, qualquer coisa
Exemplo de Midlet
P
2 Respostas
Tem o do GUJ:
esse code aqui mete uma string , usando canvas
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet {
private boolean paused;
private Display myDisplay;
private HelloCanvas myCanvas;
public HelloWorld() {
paused = false;
}
public void startApp() throws MIDletStateChanged {
// Check if this is the first time the application runs or
// if the VM resumed the app from paused state
if( paused ) {
//resume from paused state
myCanvas.repaint();
}
else {
// first run, create forms
myDisplay = Display.getDisplay( this );
myCanvas = new HelloCanvas();
myDisplay.setCurrent( myCanvas );
}
}
public void pauseApp() {
//prepare for pausing the app
paused = true;
notifyPaused();
}
public void destroyApp( boolean unconditional ) {
//clean up
// notify the system that we're ready for destruction
notifyDestroyed();
}
class HelloCanvas extends Canvas {
public void paint( Graphics g ) {
//Set color to white
g.setColor( 0x0FFFFFF );
//Fill entire screen
g.fillRect( 0, 0, getWidth(), getHeight() );
//Set color to black
g.setColor( 0 );
if( paused ) {
paused = false;
g.drawString("Welcome back", 0, 0, Graphics.TOP |
Graphics.LEFT );
}
else {
g.drawString("Hello World", 0, 0, Graphics.TOP |
Graphics.LEFT );
}
}
}
}
Criado 10 de março de 2004
Ultima resposta 11 de mar. de 2004
Respostas 2
Participantes 3