Académique Documents
Professionnel Documents
Culture Documents
Java 2 Platform
Configuration
– Defines the minimum Java technology for a broad
range of devices with similar capabilities
Profile
– Provides capabilities, on top of configuration, for a
specific device type
Java
Virtual Machine
Why do we need
a Paused state?
public HelloWorld() {
}
soft-buttons
Exit
2nd Form
Exit
Go to First Form
Saif.Braham@esprit.ens.tn Introduction to J2ME 40
Another Command Example (Two
Forms)
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
// command
Command firstFormCommand =
new Command("1st Form", "Go to First Form", Command.SCREEN, 0);
Command secondFormCommand =
new Command("2nd Form", "Go to Second Form", Command.SCREEN, 0);
Command exitCommand =
new Command("Exit", Command.EXIT, 1);
display.setCurrent( f1 );
}
Introduction to J2ME 43
Simple Debugging
System.out.print and System.out.println can be used
for debugging.
When run in the simulator, the output is put on the
console, not the phone.
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if (label.equals("Exit")) {
notifyDestroyed();
} else if (label.equals("1st Form")) {
System.out.println("1st Form is called");
display.setCurrent( f1 );
} else {
System.out.println("2nd Form is called");
display.setCurrent( f2 );
}
Introduction to J2ME 44