Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System Information Code not running

 
waqas shahwar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class SysInfo extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private Form screen;
public SysInfo() {
// Get the Display object for the MIDlet
display = Display.getDisplay(this);
// Create the Exit command
exitCommand = new Command("Exit", Command.EXIT, 2);
// Create the main screen form
screen = new Form("SysInfo");
// Obtain the current time
Calendar calendar = Calendar.getInstance();
String time = Integer.toString(calendar.get(Calendar.HOUR)) + ":" +
Integer.toString(calendar.get(Calendar.MINUTE)) + ":" +
Integer.toString(calendar.get(Calendar.SECOND));
// Obtain the total and free memory, and convert them to strings
Runtime runtime = Runtime.getRuntime();
String totalMem = Long.toString(runtime.totalMemory());
String freeMem = Long.toString(runtime.freeMemory());
// Obtain the display properties
String isColor = display.isColor() ? "Yes" : "No";
String numColors = Integer.toString(display.numColors());
// Create string items and add them to the screen
screen.append(new StringItem("", "Time: " + time));
screen.append(new StringItem("", "Total mem: " + totalMem));
screen.append(new StringItem("", "Free mem: " + freeMem));
screen.append(new StringItem("", "Color: " + isColor));
screen.append(new StringItem("", "# of colors: " + numColors));
// Set the Exit command
screen.addCommand(exitCommand);
screen.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
// Set the current display to the screen
display.setCurrent(screen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "not running"?
PS. Using the UBB [CODE]tags[/CODE] makes it easier for others to read your code snippets
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic