Home Help Search Login Register


J2meForums  |  General Category  |  Programming (Moderators: mikkom, shendley)  |  Topic: pointerPressed() working in linux but not getting called in windows environment « previous next »
Pages: [1] Print
Author

pointerPressed() working in linux but not getting called in windows environment

 (Read 153 times)
shuv
New user
*
Posts: 3



View Profile
pointerPressed() working in linux but not getting called in windows environment
« on: May 25, 2010, 02:57:28 pm »

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



View Profile
Re: pointerPressed() working in linux but not getting called in windows environment
« Reply #1 on: May 25, 2010, 04:11:21 pm »

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



View Profile
Re: pointerPressed() working in linux but not getting called in windows environment
« Reply #2 on: May 25, 2010, 04:37:01 pm »

Thanks for the response. Smiley
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.....   Huh
Logged
anuj25
New user
*
Posts: 18



View Profile
Re: pointerPressed() working in linux but not getting called in windows environment
« Reply #3 on: May 25, 2010, 06:08:57 pm »

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



View Profile
Re: pointerPressed() working in linux but not getting called in windows environment
« Reply #4 on: May 26, 2010, 07:09:02 am »

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



View Profile
Re: pointerPressed() working in linux but not getting called in windows environment
« Reply #5 on: July 29, 2010, 12:02:19 pm »

Hiee.. Smiley

Canvas method..,,
boolean hasPointerEvents()
          Checks if the platform supports pointer press and release events.
Logged
Pages: [1] Print 
J2meForums  |  General Category  |  Programming (Moderators: mikkom, shendley)  |  Topic: pointerPressed() working in linux but not getting called in windows environment « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP J2meForums | Powered by SMF 1.0.8.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!