J2ME MIDlet Problem

B

Bob Rivers

Hi,

I'm new to J2ME and I am trying to build a simple test. I want to plot
some dots on my Motorola A388 screen.

I did the code bellow, and it works well. The problem is when I try to
use a FOR loop in order to plot several dots.

If I download and install it into the cell phone, I got an error:
A388-E1008: The downloaded J2ME applications cannot be installed.

If I use the Motorola SDK 4.0 and try to install it into the emulator,
I receive the following error message (into the console): Fatal Error:
Verification failed com/innovaction/dots/Dots::<init>@8

If I remove the loop, it works well.

Any clues?

TIA,

Bob

package com.innovaction.dots;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class Dots extends MIDlet {

private Display display;
private DotsCanvas canvas;

Dots() {
canvas = new DotsCanvas();
display = Display.getDisplay(this);
}

class DotsCanvas extends Canvas {
Font font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN,
Font.SIZE_SMALL);

public void paint(Graphics g) {
g.setFont(font);
g.setColor(0);

int altura = canvas.getHeight();
int largura = canvas.getWidth();

System.out.println(">>>>>>>>>> ALTURA ORIGINAL : " + altura);
System.out.println(">>>>>>>>>> LARGURA ORIGINAL : " + largura);

altura = altura - (altura / 3);
largura = largura - (largura / 3);

System.out.println(">>>>>>>>>> ALTURA REDUZIDA : " + altura);
System.out.println(">>>>>>>>>> LARGURA REDUZIDA : " + largura);


int yInicial = (canvas.getHeight() - altura)/2;
int xInicial = (canvas.getWidth() - largura)/2;

System.out.println(">>>>>>>>>> yInicial : " + yInicial);
System.out.println(">>>>>>>>>> xInicial : " + xInicial);

g.drawString(".", xInicial, yInicial, 0);

for (int i = 0; i < 200; i++) {
System.out.println(">>> i : " + i);
}

g.drawLine(10, 20, 50, 20);
}

}

public void startApp() throws MIDletStateChangeException {
display.setCurrent(canvas);
}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top