J2ME, Canvas, keyPressed event detect fail....

B

boki

Hi All,
This my GUI.java, the KeyPressed() funtion never trigger a key,
what is wrong here...,

Debug output:(by system.out.println())
-----------------------------
Canvas super
Canvas 3
Boki Start
Run of Canvas
try2
----------------------------
/***
myMidlet.java
***/

....
....
....
public void startApp(){
gui = new GUI ();
display = Display.getDisplay(this);
display.setCurrent(gui)
System.out.println("Boki Start");
....
....
....

----------------------------
/**
* GUI.java
*/
package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.game.*;
import javax.microedition.media.*;
import java.io.*;
import java.util.*;

import java.io.InputStream;
import java.io_OutputStream;
import java.io.IOException;
import javax.microedition.io.*;


import java.io.*;
import javax.microedition.io.*;
import javax.bluetooth.*;



public class GUI extends Canvas implements Runnable{
private Thread myThread;
private int k=0;

public GUI () {
super();

myThread = new Thread(this);
myThread.start();
System.out.println("Canvas super");
}

public void run()
{
System.out.println("Run of Canvas");




}

public void paint (Graphics g)
{

System.out.println("Canvas 3");
}

protected void keyPressed (int keyCode)
{
System.out.println("GUI keyPressed");
}

}
 
B

Boki

just set a wrong display.setCurrent(gui)

but the commands of GUI never show, why ?????
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top