This application works correctly in Sun Java Wireless Toolkit and shows screen size, but on real mobile phone shows 0x0.

MobiProp.java:

Java Code:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class MobiProp extends MIDlet implements CommandListener {
	private XY xy;
	private Display display;
	private Form props;
	private Command exitCommand = new Command("Koniec", Command.EXIT, 1);
	private StringBuffer propbuf;
	int width, height;
	
	public MobiProp() {
		display = Display.getDisplay(this);
		xy = new XY(this);
		props = new Form("Konfiguracja systemu");
		
		
	}
	
	public void startApp() {
		display.setCurrent(xy);
		Runtime runtime = Runtime.getRuntime();
        runtime.gc();
		propbuf = new StringBuffer(50);
		props.append("Ekran: x=" + width + " y=" + height + "\n");
        props.append(showProp("microedition.configuration","Konfiguracja"));
        props.append(showProp("microedition.profiles","Profil"));
        props.append(showProp("microedition.platform","Platforma"));
        props.append(showProp("microedition.locale","Lokalizacja"));
        props.append(showProp("microedition.encoding","Strona kodowa"));
		props.append("----------------------");
		props.append("\n");
		props.append("2014(c)CompSoft");
		
		props.addCommand(exitCommand);
        props.setCommandListener(this);
		
		display.setCurrent(props);
	}

	public void commandAction(Command c, Displayable s) {
        if (c == exitCommand) {
            destroyApp(false);
            notifyDestroyed();
        }
    }
    String showProp(String prop, String opis) {
        String value = System.getProperty(prop);
        propbuf.setLength(0);
        propbuf.append(opis);
        propbuf.append(": ");

        if (value == null) {
            propbuf.append("<undefined>");
        } else {
            propbuf.append("\"");
            propbuf.append(value);
            propbuf.append("\"");
        }

        propbuf.append("\n");

        return propbuf.toString();
    }	
	public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
	
	public void zakoncz() {
		destroyApp(true);
		notifyDestroyed();
	}
}
XY.java:
Java Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

class XY extends Canvas  {
	private MobiProp MojMIDlet;

	public XY(MobiProp MojMIDlet) {
		this.MojMIDlet = MojMIDlet;
	}

	public void paint(Graphics g) {
		MojMIDlet.width = getWidth();
		MojMIDlet.height = getHeight();
	}
	
	protected void keyPressed(int key) {
	}
}