SysPropFullCanvas.java
/**
* Copyright (c) 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example.systemproperties;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Font;
public class SysPropFullCanvas extends Canvas implements CommandListener {
private SystemProperties midlet;
private Command backCommand;
private Command exitCommand;
private int w, h, fontheight;
private Font font;
private String value;
public SysPropFullCanvas(SystemProperties midlet) {
this.midlet = midlet;
this.setFullScreenMode(true);
backCommand = new Command("Back", Command.BACK, 1);
exitCommand = new Command("Exit", Command.EXIT, 1);
this.setCommandListener(this);
this.addCommand(backCommand);
this.addCommand(exitCommand);
font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
fontheight = font.getHeight();
}
protected void paint(Graphics g) {
w = this.getWidth();
h = this.getHeight();
g.setColor(255, 255, 255); // Background color
g.fillRect(0, 0, w, h);
g.setColor(0, 0, 0); // Text color
g.setFont(font);
update(SystemProperties.NOKIA_CANVAS_UI, g);
}
public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
midlet.showList();
}
if (c == exitCommand) {
midlet.notifyDestroyed();
}
}
protected void update(String[] list, Graphics g) {
int length = list.length;
for (int i = 0; i < length; i++) {
value = System.getProperty(list[i]);
if (value == null) {
value = "null";
}
g.drawString(list[i], 0, (i * 2) * fontheight, Graphics.LEFT | Graphics.TOP);
g.drawString(value, 0, (i * 2) * fontheight + fontheight, Graphics.LEFT | Graphics.TOP);
}
}
}