|
|
Pages: [1]
|
 |
|
Author
|
pointerPressed() working in linux but not getting called in windows environment (Read 153 times)
|
shuv
New user

Posts: 3
|
hi all, i am a beginner in j2me and this is my first post over here. I am facing one typical problem. I have overriden pointerPressed() function in the file ViewFriend.java. Testing the code on emulator, the pointerPressed() function is not getting called in the windows environment but on the linux environment it's working fine. But I need to run this code on the windows XP environment(as I am doing my whole project there).
PS: emulators used in both the environments are same.
Can you please tell what may be the problem or how to resolve?
Following is the code which I have written:
File Name: FocusCell.java
import javax.microedition.lcdui.Display; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException;
public class FocusCell extends MIDlet { Display display; ViewFriend vf; public FocusCell() { // TODO Auto-generated constructor stub }
protected void destroyApp(boolean arg0) throws MIDletStateChangeException { // TODO Auto-generated method stub
}
protected void pauseApp() { // TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException { // TODO Auto-generated method stub vf = new ViewFriend(); display = Display.getDisplay( this ); display.setCurrent(vf); }
}
File Name: ViewFriend.java
import java.io.IOException;
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image;
public class ViewFriend extends Canvas implements CommandListener{ Image image1; int X , Y ; boolean pointer; public ViewFriend() { try { image1 = Image.createImage("/friend.jpg"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } protected void paint(Graphics g) { // TODO Auto-generated method stub int width = getWidth(); int height = getHeight(); g.setColor(255, 255, 255); g.fillRect(0, 0, width, height); g.setColor(0xffffff); g.drawImage(image1,0,0,Graphics.TOP | Graphics.LEFT); if(pointer) { g.drawString("this.X"+X+"this.Y"+Y, 10, 10, Graphics.TOP|Graphics.LEFT); System.out.println("Pointer pressed"); } } protected void pointerPressed(int x, int y) { X=x; Y=y; pointer=true; System.out.println("in pointer presesd"); repaint(); }
public void commandAction(Command arg0, Displayable arg1) { // TODO Auto-generated method stub } }
|
|
|
|
|
Logged
|
|
|
|
anuj25
New user

Posts: 18
|
paint code write twice one with true boolean value and other false. make this boolean value change at pointerPressed. I think this is correct method as paint is called itself so a check should be made.
|
|
|
|
|
Logged
|
|
|
|
shuv
New user

Posts: 3
|
Thanks for the response.  The pointerPressed() function is not getting invoked at all in the windows environment. To test this there is a line: System.out.println("in pointer presesd"); .... Nothing gets printed in the console when the pointer key is pressed....
And I already did wat u hav said... changed the boolean value in the pointerPressed(int,int) function itself..
The code is running fine in linux but in the windows environment pointerPressed() is not getting invoked on same emulator.....
|
|
|
|
|
Logged
|
|
|
|
anuj25
New user

Posts: 18
|
well check ur emulator setting..is it enabled for touch phone in win environment. what else could be.. ??
|
|
|
|
|
Logged
|
|
|
|
shuv
New user

Posts: 3
|
plz tell how to do that in Sun Java Wireless Toolkit 2.5.2 .........
|
|
|
|
|
Logged
|
|
|
|
madhu.s
New user

Posts: 1
|
Hiee.. 
Canvas method..,, boolean hasPointerEvents() Checks if the platform supports pointer press and release events.
|
|
|
|
|
Logged
|
|
|
|
|
Pages: [1]
|
|
|
|
|